2022-10-21 20:06:43 +00:00
|
|
|
<?php
|
|
|
|
|
2023-06-05 21:46:41 +00:00
|
|
|
namespace App\Http\Controllers\API;
|
2022-10-21 20:06:43 +00:00
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Http\Resources\GenreResource;
|
|
|
|
use App\Repositories\GenreRepository;
|
|
|
|
use Illuminate\Http\Response;
|
|
|
|
|
|
|
|
class GenreController extends Controller
|
|
|
|
{
|
|
|
|
public function __construct(private GenreRepository $repository)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
return GenreResource::collection($this->repository->getAll());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function show(string $name)
|
|
|
|
{
|
|
|
|
$genre = $this->repository->getOne($name);
|
2022-11-27 15:29:29 +00:00
|
|
|
abort_unless((bool) $genre, Response::HTTP_NOT_FOUND);
|
2022-10-21 20:06:43 +00:00
|
|
|
|
|
|
|
return GenreResource::make($genre);
|
|
|
|
}
|
|
|
|
}
|