clrghouz/app/Policies/UserPolicy.php

87 lines
1.5 KiB
PHP

<?php
namespace App\Policies;
use App\Models\User;
class UserPolicy
{
/**
* Does this user have admin privileges
*
* @param User $user
* @return bool
*/
public function admin(User $user): bool
{
return $user->isAdmin();
}
/**
* Does this user own the model?
*
* @param User $user
* @param User $model
* @return bool
*/
public function ownes(User $user,User $model): bool
{
return $user->id === $model->id;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return FALSE;
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, User $model): bool
{
return FALSE;
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return FALSE;
}
/**
* Determine whether the user can update the model, or if the user is an admin, and thus they can update all users.
*/
public function update(User $user, User $model): bool
{
return $user->isAdmin() || ($model->id === $user->id);
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, User $model): bool
{
return FALSE;
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, User $model): bool
{
return FALSE;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, User $model): bool
{
return FALSE;
}
}