is_smart) { $this->authorize('own', $playlist); return SongResource::collection($this->smartPlaylistService->getSongs($playlist, $this->user)); } $this->authorize('collaborate', $playlist); return self::createResourceCollection($this->songRepository->getByStandardPlaylist($playlist, $this->user)); } public function store(Playlist $playlist, AddSongsToPlaylistRequest $request) { abort_if($playlist->is_smart, Response::HTTP_FORBIDDEN, 'Smart playlist content is automatically generated'); $this->authorize('collaborate', $playlist); $songs = $this->songRepository->getMany(ids: $request->songs, scopedUser: $this->user); return self::createResourceCollection($this->playlistService->addSongsToPlaylist($playlist, $songs, $this->user)); } private static function createResourceCollection(Collection $songs): ResourceCollection { return License::isPlus() ? CollaborativeSongResource::collection($songs) : SongResource::collection($songs); } public function destroy(Playlist $playlist, RemoveSongsFromPlaylistRequest $request) { abort_if($playlist->is_smart, Response::HTTP_FORBIDDEN, 'Smart playlist content is automatically generated'); $this->authorize('collaborate', $playlist); $this->playlistService->removeSongsFromPlaylist($playlist, $request->songs); return response()->noContent(); } }