46 lines
1006 B
PHP
46 lines
1006 B
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\User;
|
|
|
|
class UserPolicy
|
|
{
|
|
public function viewAny(User $actor): bool
|
|
{
|
|
return $actor->isAdmin();
|
|
}
|
|
|
|
public function create(User $actor): bool
|
|
{
|
|
return $actor->isAdmin();
|
|
}
|
|
|
|
public function update(User $actor, User $target): bool
|
|
{
|
|
return $actor->isAdmin() && $actor->id !== $target->id;
|
|
}
|
|
|
|
public function delete(User $actor, User $target): bool
|
|
{
|
|
return $actor->isAdmin()
|
|
&& $actor->id !== $target->id
|
|
&& ! $target->hasUsage();
|
|
}
|
|
|
|
public function activate(User $actor, User $target): bool
|
|
{
|
|
return $actor->isAdmin() && $actor->id !== $target->id;
|
|
}
|
|
|
|
public function deactivate(User $actor, User $target): bool
|
|
{
|
|
return $actor->isAdmin() && $actor->id !== $target->id;
|
|
}
|
|
|
|
public function changeEmail(User $actor, User $target): bool
|
|
{
|
|
return $actor->isAdmin() && $actor->id !== $target->id;
|
|
}
|
|
}
|