authorize('own', $playlist); return SongResource::collection( $playlist->is_smart ? $this->smartPlaylistService->getSongs($playlist, $this->user) : $this->songRepository->getByStandardPlaylist($playlist, $this->user) ); } public function store(Playlist $playlist, AddSongsToPlaylistRequest $request) { $this->authorize('own', $playlist); $this->songRepository->getMany(ids: $request->songs, scopedUser: $this->user) ->each(fn ($song) => $this->authorize('access', $song)); abort_if($playlist->is_smart, Response::HTTP_FORBIDDEN); $this->playlistService->addSongsToPlaylist($playlist, $request->songs); return response()->noContent(); } public function destroy(Playlist $playlist, RemoveSongsFromPlaylistRequest $request) { $this->authorize('own', $playlist); abort_if($playlist->is_smart, Response::HTTP_FORBIDDEN); $this->playlistService->removeSongsFromPlaylist($playlist, $request->songs); return response()->noContent(); } }