. */ namespace Poniverse\Ponyfm\Http\Controllers\Api\Web; use Input; use Poniverse\Ponyfm\Commands\RenameGenreCommand; use Poniverse\Ponyfm\Genre; use Poniverse\Ponyfm\Http\Controllers\ApiControllerBase; use Response; class GenresController extends ApiControllerBase { public function getIndex() { $this->authorize('access-admin-area'); $genres = Genre::with(['trackCountRelation' => function($query) { $query->withTrashed(); }]) ->orderBy('name', 'asc') ->get(); return Response::json([ 'genres' => $genres->toArray() ], 200); } public function putRename($genreId) { $command = new RenameGenreCommand($genreId, Input::get('name')); return $this->execute($command); } }