mirror of
https://github.com/koel/koel
synced 2024-12-21 10:03:10 +00:00
28 lines
640 B
PHP
28 lines
640 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Policies;
|
||
|
|
||
|
use App\Facades\License;
|
||
|
use App\Models\Artist;
|
||
|
use App\Models\Song;
|
||
|
use App\Models\User;
|
||
|
use Illuminate\Auth\Access\Response;
|
||
|
|
||
|
class ArtistPolicy
|
||
|
{
|
||
|
public function update(User $user, Artist $artist): Response
|
||
|
{
|
||
|
if ($user->is_admin) {
|
||
|
return Response::allow();
|
||
|
}
|
||
|
|
||
|
if (License::isCommunity()) {
|
||
|
return Response::deny('This action is unauthorized.');
|
||
|
}
|
||
|
|
||
|
return $artist->songs->every(static fn (Song $song) => $song->ownedBy($user))
|
||
|
? Response::allow()
|
||
|
: Response::deny('Artist is not owned by the user.');
|
||
|
}
|
||
|
}
|