2022-08-10 14:56:01 +00:00
|
|
|
<?php
|
|
|
|
|
2023-06-05 21:46:41 +00:00
|
|
|
namespace App\Http\Controllers\API;
|
2022-08-10 14:56:01 +00:00
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2023-06-05 21:46:41 +00:00
|
|
|
use App\Http\Requests\API\PlaylistFolderPlaylistDestroyRequest;
|
|
|
|
use App\Http\Requests\API\PlaylistFolderPlaylistStoreRequest;
|
2022-08-10 14:56:01 +00:00
|
|
|
use App\Models\PlaylistFolder;
|
|
|
|
use App\Services\PlaylistFolderService;
|
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
|
|
|
|
class PlaylistFolderPlaylistController extends Controller
|
|
|
|
{
|
|
|
|
public function __construct(private PlaylistFolderService $service)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function store(PlaylistFolder $playlistFolder, PlaylistFolderPlaylistStoreRequest $request)
|
|
|
|
{
|
|
|
|
$this->authorize('own', $playlistFolder);
|
|
|
|
|
|
|
|
$this->service->addPlaylistsToFolder($playlistFolder, Arr::wrap($request->playlists));
|
|
|
|
|
|
|
|
return response()->noContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function destroy(PlaylistFolder $playlistFolder, PlaylistFolderPlaylistDestroyRequest $request)
|
|
|
|
{
|
|
|
|
$this->authorize('own', $playlistFolder);
|
|
|
|
|
2024-03-27 09:53:05 +00:00
|
|
|
$this->service->movePlaylistsToRootLevel($playlistFolder, Arr::wrap($request->playlists));
|
2022-08-10 14:56:01 +00:00
|
|
|
|
|
|
|
return response()->noContent();
|
|
|
|
}
|
|
|
|
}
|