1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2024-11-25 03:43:33 +01:00
freescout/app/Policies/UserPolicy.php
2018-07-24 06:34:28 +00:00

79 lines
1.5 KiB
PHP

<?php
namespace App\Policies;
use App\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class UserPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view the model.
*
* @param \App\User $user
* @param \App\User $model
*
* @return mixed
*/
public function view(User $user, User $model)
{
if ($user->isAdmin() || $user->id == $model->id) {
return true;
} else {
return false;
}
}
/**
* Determine whether the user can create models.
*
* @param \App\User $user
*
* @return mixed
*/
public function create(User $user)
{
if ($user->isAdmin()) {
return true;
} else {
return false;
}
}
/**
* Determine whether the user can update the model.
*
* @param \App\User $user
* @param \App\User $model
*
* @return mixed
*/
public function update(User $user, User $model)
{
if ($user->isAdmin() || $user->id == $model->id) {
return true;
} else {
return false;
}
}
/**
* Determine whether the user can delete the model.
*
* @param \App\User $user
* @param \App\User $model
*
* @return mixed
*/
public function delete(User $user, User $model)
{
if ($user->isAdmin() || $user->id == $model->id) {
return true;
} else {
return false;
}
}
}