mirror of
https://github.com/koel/koel
synced 2024-11-24 05:03:05 +00:00
31 lines
758 B
PHP
31 lines
758 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Models\PlaylistFolder;
|
|
use App\Models\User;
|
|
|
|
class PlaylistFolderService
|
|
{
|
|
public function createFolder(User $user, string $name): PlaylistFolder
|
|
{
|
|
return $user->playlist_folders()->create(['name' => $name]);
|
|
}
|
|
|
|
public function renameFolder(PlaylistFolder $folder, string $name): PlaylistFolder
|
|
{
|
|
$folder->update(['name' => $name]);
|
|
|
|
return $folder;
|
|
}
|
|
|
|
public function addPlaylistsToFolder(PlaylistFolder $folder, array $playlistIds): void
|
|
{
|
|
$folder->playlists()->attach($playlistIds);
|
|
}
|
|
|
|
public function movePlaylistsToRootLevel(PlaylistFolder $folder, array $playlistIds): void
|
|
{
|
|
$folder->playlists()->detach($playlistIds);
|
|
}
|
|
}
|