koel/app/Policies/SongPolicy.php

40 lines
1,015 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 play(User $user, Song $song): bool
{
return License::isCommunity() || $song->is_public || $song->owner_id === $user->id;
}
2024-01-06 22:28:31 +00:00
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;
}
2024-01-07 12:43:10 +00:00
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;
}
2024-01-03 17:02:18 +00:00
}