2015-12-14 16:27:26 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Policies;
|
|
|
|
|
2024-01-03 17:02:18 +00:00
|
|
|
use App\Facades\License;
|
2015-12-14 16:27:26 +00:00
|
|
|
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
|
2015-12-14 16:27:26 +00:00
|
|
|
{
|
2022-07-27 08:49:33 +00:00
|
|
|
return $currentUser->is_admin && $currentUser->isNot($userToDestroy);
|
2015-12-14 16:27:26 +00:00
|
|
|
}
|
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;
|
|
|
|
}
|
2015-12-14 16:27:26 +00:00
|
|
|
}
|