koel/app/Repositories/PlaylistRepository.php
2024-07-06 17:44:44 +02:00

21 lines
493 B
PHP

<?php
namespace App\Repositories;
use App\Facades\License;
use App\Models\Playlist;
use App\Models\User;
use Illuminate\Support\Collection;
class PlaylistRepository extends Repository
{
/** @return array<array-key, Playlist>|Collection<Playlist> */
public function getAllAccessibleByUser(User $user): Collection
{
if (License::isCommunity()) {
return $user->playlists;
}
return $user->playlists->merge($user->collaboratedPlaylists);
}
}