koel/app/Policies/UserPolicy.php

27 lines
646 B
PHP
Raw Normal View History

<?php
namespace App\Policies;
2024-01-03 17:02:18 +00:00
use App\Facades\License;
use App\Models\User;
class UserPolicy
{
2022-06-10 10:47:46 +00:00
public function admin(User $currentUser): bool
{
return $currentUser->is_admin;
}
2018-08-24 15:27:19 +00:00
public function destroy(User $currentUser, User $userToDestroy): bool
{
2022-07-27 08:49:33 +00:00
return $currentUser->is_admin && $currentUser->isNot($userToDestroy);
}
2024-01-03 17:02:18 +00:00
public function upload(User $currentUser): bool
{
// For Community Edition, only admins can upload songs.
// For Plus Edition, any user can upload songs (to their own library).
return License::isCommunity() ? $currentUser->is_admin : true;
}
}