Files
movies/app/Http/Controllers/MovieController.php
T

38 lines
943 B
PHP
Raw Normal View History

2025-01-26 21:36:05 +02:00
<?php
namespace App\Http\Controllers;
2025-01-29 22:33:09 +02:00
use App\Models\Comment;
2025-01-26 21:36:05 +02:00
use App\Models\Movie;
use Illuminate\Http\Request;
class MovieController extends Controller
{
public function index()
{
$movies = Movie::orderBy('release_date', 'ASC')->paginate(60);
return view('movie.index', compact('movies'));
}
public function show(string $slug)
{
$movie = Movie::with('director', 'watchProviders')
->where('slug', $slug)
->firstOrFail();
2025-01-29 22:33:09 +02:00
// comments
$comments = Comment::where(function($query) use ($movie){
$query->where(function($query) use ($movie){
$query->where('entity_id', $movie->id)
->where('entity_type', Comment::TYPE_MOVIE);
})
->orWhere('tmdb_id', $movie->tmdb_id);
})
->paginate(15);
return view('movie.show', compact('movie', 'comments'));
2025-01-26 21:36:05 +02:00
}
}