27 lines
695 B
PHP
27 lines
695 B
PHP
<?php
|
|
|
|
namespace App\Modules\Movies\Services\Browse;
|
|
|
|
use App\Modules\Movies\Models\Movie;
|
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|
use App\Modules\Movies\Services\Contracts\ShowMovieServiceInterface;
|
|
|
|
class ShowMovieService implements ShowMovieServiceInterface
|
|
{
|
|
/**
|
|
* Fetch a single movie with its relations by ID.
|
|
*/
|
|
public function getById(int $id): Movie
|
|
{
|
|
$movie = Movie::query()
|
|
->with(['genres', 'actors', 'directors', 'studios', 'countries', 'languages'])
|
|
->find($id);
|
|
|
|
if (!$movie) {
|
|
throw (new ModelNotFoundException())->setModel(Movie::class, [$id]);
|
|
}
|
|
|
|
return $movie;
|
|
}
|
|
}
|