. */ 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\Http\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(Request $request) { $command = new CreateGenreCommand($request->get('name')); return $this->execute($command); } public function putRename(Request $request, $genreId) { $command = new RenameGenreCommand($genreId, $request->get('name')); return $this->execute($command); } public function deleteGenre(Request $request, $genreId) { $command = new DeleteGenreCommand($genreId, $request->get('destination_genre_id')); return $this->execute($command); } }