first
This commit is contained in:
45
app/Policies/UserPolicy.php
Normal file
45
app/Policies/UserPolicy.php
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user