Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

81 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2019-04-22 19:01:39 -05:00
<?php
namespace App\Policies;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class UserPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can manage users.
*
2021-03-24 15:13:43 +01:00
* @param User $user
2019-04-22 19:01:39 -05:00
* @return bool
*/
public function manage(User $user)
{
return $user->isAdmin();
}
/**
* Determine whether the user can view the user.
*
2021-03-24 15:13:43 +01:00
* @param User $user
* @param User $target
2019-04-22 19:01:39 -05:00
* @return bool
*/
public function view(User $user, User $target)
{
return $user->isAdmin() || $target->is($user);
}
2020-05-23 19:05:18 +02:00
/**
* Determine whether the user can view any user.
*
2021-09-08 23:35:56 +02:00
* @param User $user
2020-05-23 19:05:18 +02:00
* @return mixed
*/
public function viewAny(User $user)
{
return $user->isAdmin();
}
2019-04-22 19:01:39 -05:00
/**
* Determine whether the user can create users.
*
2021-03-24 15:13:43 +01:00
* @param User $user
2019-04-22 19:01:39 -05:00
* @return bool
*/
public function create(User $user)
{
return $user->isAdmin();
}
/**
* Determine whether the user can update the user.
*
2021-03-24 15:13:43 +01:00
* @param User $user
* @param User $target
2019-04-22 19:01:39 -05:00
* @return bool
*/
public function update(User $user, User $target)
{
return $user->isAdmin() || $target->is($user);
}
/**
* Determine whether the user can delete the user.
*
2021-03-24 15:13:43 +01:00
* @param User $user
* @param User $target
2019-04-22 19:01:39 -05:00
* @return bool
*/
public function delete(User $user, User $target)
{
return $user->isAdmin();
}
}