. */ namespace App\Http\Controllers\Api\Web; use App\Commands\CreateGenreCommand; use App\Commands\DeleteGenreCommand; use App\Commands\RenameGenreCommand; use App\Http\Controllers\ApiControllerBase; use App\Models\Genre; use Illuminate\Support\Facades\Request; use Illuminate\Support\Facades\Response; class GenresController extends ApiControllerBase { public function getIndex() { $this->authorize('access-admin-area'); $genres = Genre::with(['trackCountRelation' => function ($query) { $query->withTrashed(); }]) ->orderBy('name') ->get(); return response()->json([ 'genres' => $genres->toArray(), ], 200); } public function postCreate() { $command = new CreateGenreCommand(Request::get('name')); return $this->execute($command); } public function putRename($genreId) { $command = new RenameGenreCommand($genreId, Request::get('name')); return $this->execute($command); } public function deleteGenre($genreId) { $command = new DeleteGenreCommand($genreId, Request::get('destination_genre_id')); return $this->execute($command); } }