mirror of
https://github.com/koel/koel
synced 2025-02-26 04:07:18 +00:00
25 lines
516 B
PHP
25 lines
516 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Services;
|
||
|
|
||
|
use App\Models\Playlist;
|
||
|
use App\Models\User;
|
||
|
|
||
|
class PlaylistService
|
||
|
{
|
||
|
public function createPlaylist(string $name, User $user, array $songs, array $ruleGroups): Playlist
|
||
|
{
|
||
|
/** @var Playlist $playlist */
|
||
|
$playlist = $user->playlists()->create([
|
||
|
'name' => $name,
|
||
|
'rules' => $ruleGroups,
|
||
|
]);
|
||
|
|
||
|
if (!$playlist->is_smart && $songs) {
|
||
|
$playlist->songs()->sync($songs);
|
||
|
}
|
||
|
|
||
|
return $playlist;
|
||
|
}
|
||
|
}
|