songRepository->getForListing( $request->sort ?: 'songs.title', $request->order ?: 'asc', $this->user ) ); } public function show(Song $song) { return SongResource::make($this->songRepository->getOne($song->id)); } public function update(SongUpdateRequest $request) { $this->authorize('admin', $this->user); $updatedSongs = $this->songService->updateSongs($request->songs, SongUpdateData::fromRequest($request)); $albums = $this->albumRepository->getByIds($updatedSongs->pluck('album_id')->toArray()); $artists = $this->artistRepository->getByIds( array_merge( $updatedSongs->pluck('artist_id')->all(), $updatedSongs->pluck('album_artist_id')->all() ) ); return response()->json([ 'songs' => SongResource::collection($updatedSongs), 'albums' => AlbumResource::collection($albums), 'artists' => ArtistResource::collection($artists), 'removed' => $this->libraryManager->prune(), ]); } public function destroy(DeleteSongsRequest $request) { $this->authorize('admin', $this->user); $this->songService->deleteSongs($request->songs); return response()->noContent(); } }