playlists()->create([ 'name' => $name, 'rules' => $ruleGroups, ]); if (!$playlist->is_smart && $songs) { $playlist->songs()->sync($songs); } return $playlist; } public function addSongsToPlaylist(Playlist $playlist, array $songIds): void { $playlist->songs()->syncWithoutDetaching($songIds); } public function removeSongsFromPlaylist(Playlist $playlist, array $songIds): void { $playlist->songs()->detach($songIds); } /** @deprecated */ public function populatePlaylist(Playlist $playlist, array $songIds): void { $playlist->songs()->sync($songIds); } }