2015-12-14 16:27:26 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Policies;
|
|
|
|
|
2024-01-18 11:13:05 +00:00
|
|
|
use App\Facades\License;
|
2015-12-14 16:27:26 +00:00
|
|
|
use App\Models\Playlist;
|
2015-12-15 00:48:48 +00:00
|
|
|
use App\Models\User;
|
2015-12-14 16:27:26 +00:00
|
|
|
|
|
|
|
class PlaylistPolicy
|
|
|
|
{
|
2022-08-10 14:56:01 +00:00
|
|
|
public function own(User $user, Playlist $playlist): bool
|
2015-12-14 16:27:26 +00:00
|
|
|
{
|
2024-01-18 11:13:05 +00:00
|
|
|
return $playlist->ownedBy($user);
|
2015-12-14 16:27:26 +00:00
|
|
|
}
|
2024-01-07 12:43:10 +00:00
|
|
|
|
|
|
|
public function download(User $user, Playlist $playlist): bool
|
|
|
|
{
|
|
|
|
return $this->own($user, $playlist);
|
|
|
|
}
|
2024-01-18 11:13:05 +00:00
|
|
|
|
|
|
|
public function inviteCollaborators(User $user, Playlist $playlist): bool
|
|
|
|
{
|
|
|
|
return $this->own($user, $playlist) && !$playlist->is_smart && License::isPlus();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function collaborate(User $user, Playlist $playlist): bool
|
|
|
|
{
|
|
|
|
if ($this->own($user, $playlist)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!License::isPlus()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $playlist->hasCollaborator($user);
|
|
|
|
}
|
2015-12-14 16:27:26 +00:00
|
|
|
}
|