playlistRepository->getAllAccessibleByUser($this->user)); } public function store(PlaylistStoreRequest $request) { $folder = null; if ($request->folder_id) { $folder = $this->folderRepository->getOne($request->folder_id); $this->authorize('own', $folder); } try { $playlist = $this->playlistService->createPlaylist( $request->name, $this->user, $folder, Arr::wrap($request->songs), $request->rules ? SmartPlaylistRuleGroupCollection::create(Arr::wrap($request->rules)) : null, $request->own_songs_only && $request->rules && License::isPlus() ); return PlaylistResource::make($playlist); } catch (PlaylistBothSongsAndRulesProvidedException $e) { throw ValidationException::withMessages(['songs' => [$e->getMessage()]]); } } public function update(PlaylistUpdateRequest $request, Playlist $playlist) { $this->authorize('own', $playlist); $folder = null; if ($request->folder_id) { $folder = $this->folderRepository->getOne($request->folder_id); $this->authorize('own', $folder); } return PlaylistResource::make( $this->playlistService->updatePlaylist( $playlist, $request->name, $folder, $request->rules ? SmartPlaylistRuleGroupCollection::create(Arr::wrap($request->rules)) : null, $request->own_songs_only && $request->rules && License::isPlus() ) ); } public function destroy(Playlist $playlist) { $this->authorize('own', $playlist); $playlist->delete(); return response()->noContent(); } }