This commit is contained in:
Saufi
2026-06-02 17:35:45 +08:00
commit 4ef99b1f81
148 changed files with 21134 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?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;
}
}