mirror of
https://github.com/koel/koel
synced 2025-02-26 04:07:18 +00:00
39 lines
1,015 B
PHP
39 lines
1,015 B
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Facades\License;
|
|
use App\Models\Song;
|
|
use App\Models\User;
|
|
|
|
class SongPolicy
|
|
{
|
|
public function play(User $user, Song $song): bool
|
|
{
|
|
return License::isCommunity() || $song->is_public || $song->owner_id === $user->id;
|
|
}
|
|
|
|
public function interact(User $user, Song $song): bool
|
|
{
|
|
return License::isCommunity() || $song->is_public || $song->owner_id === $user->id;
|
|
}
|
|
|
|
public function delete(User $user, Song $song): bool
|
|
{
|
|
return (License::isCommunity() && $user->is_admin) || $song->owner_id === $user->id;
|
|
}
|
|
|
|
public function edit(User $user, Song $song): bool
|
|
{
|
|
return (License::isCommunity() && $user->is_admin) || $song->owner_id === $user->id;
|
|
}
|
|
|
|
public function download(User $user, Song $song): bool
|
|
{
|
|
if (!config('koel.download.allow')) {
|
|
return false;
|
|
}
|
|
|
|
return License::isCommunity() || $song->is_public || $song->owner_id === $user->id;
|
|
}
|
|
}
|