koel/app/Http/Controllers/API/PlaylistFolderPlaylistController.php

36 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2023-06-05 21:46:41 +00:00
namespace App\Http\Controllers\API;
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;
use App\Models\PlaylistFolder;
use App\Services\PlaylistFolderService;
use Illuminate\Support\Arr;
class PlaylistFolderPlaylistController extends Controller
{
2024-04-18 14:36:28 +00:00
public function __construct(private readonly 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);
$this->service->movePlaylistsToRootLevel($playlistFolder, Arr::wrap($request->playlists));
return response()->noContent();
}
}