koel/app/Policies/SongPolicy.php

36 lines
824 B
PHP
Raw Normal View History

2024-01-03 17:02:18 +00:00
<?php
namespace App\Policies;
use App\Facades\License;
use App\Models\Song;
use App\Models\User;
class SongPolicy
{
public function own(User $user, Song $song): bool
{
return $song->owner_id === $user->id;
}
2024-01-09 11:53:35 +00:00
public function access(User $user, Song $song): bool
2024-01-03 17:02:18 +00:00
{
2024-01-09 11:53:35 +00:00
return License::isCommunity() || $song->accessibleBy($user);
2024-01-06 22:28:31 +00:00
}
public function delete(User $user, Song $song): bool
{
return (License::isPlus() && $song->ownedBy($user)) || $user->is_admin;
2024-01-06 22:28:31 +00:00
}
public function edit(User $user, Song $song): bool
{
2024-01-09 11:53:35 +00:00
return (License::isPlus() && $song->accessibleBy($user)) || $user->is_admin;
2024-01-06 22:28:31 +00:00
}
2024-01-07 12:43:10 +00:00
public function download(User $user, Song $song): bool
{
return config('koel.download.allow') && $this->access($user, $song);
2024-01-07 12:43:10 +00:00
}
2024-01-03 17:02:18 +00:00
}