authorize('upload', User::class); try { // @todo decouple Song from storage, as storages should not be responsible for creating a song. $song = $songRepository->getOne($storage->storeUploadedFile($request->file, $user)->id, $user); return response()->json([ 'song' => SongResource::make($song), 'album' => AlbumResource::make($albumRepository->getOne($song->album_id)), ]); } catch (MediaPathNotSetException $e) { abort(Response::HTTP_FORBIDDEN, $e->getMessage()); } catch (SongUploadFailedException $e) { abort(Response::HTTP_BAD_REQUEST, $e->getMessage()); } } }