mirror of https://github.com/kcal-app/kcal.git
27 lines
537 B
PHP
27 lines
537 B
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
|
|
|
class UserPolicy
|
|
{
|
|
use HandlesAuthorization;
|
|
|
|
/**
|
|
* Determine whether the user can administer (the application).
|
|
*/
|
|
public function administer(User $user): bool {
|
|
return $user->admin;
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can delete the model.
|
|
*/
|
|
public function delete(User $user, User $model): bool
|
|
{
|
|
return $this->administer($user) && $user->id !== $model->id;
|
|
}
|
|
}
|