koel/app/Repositories/PlaylistRepository.php
2024-01-22 23:24:07 +01: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);
}
}