2020-06-26 23:32:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Policies;
|
|
|
|
|
|
|
|
use App\User;
|
|
|
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
|
|
|
|
|
|
|
class UserPolicy
|
|
|
|
{
|
|
|
|
use HandlesAuthorization;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new policy instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
2020-10-21 00:29:50 +00:00
|
|
|
|
2020-06-26 23:32:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function edit(User $authUser, User $user)
|
|
|
|
{
|
|
|
|
return $authUser->is($user) || $authUser->hasRole('admin');
|
|
|
|
}
|
|
|
|
|
2020-07-16 20:21:28 +00:00
|
|
|
// This refers to the admin tools that let staff update more information than users themselves can
|
|
|
|
public function adminEdit(User $authUser, User $user)
|
|
|
|
{
|
2020-10-21 00:29:50 +00:00
|
|
|
return $authUser->hasRole('admin') && $authUser->isNot($user);
|
2020-07-16 20:21:28 +00:00
|
|
|
}
|
|
|
|
|
2020-06-26 23:32:33 +00:00
|
|
|
public function viewStaff(User $user)
|
|
|
|
{
|
|
|
|
return $user->can('admin.stafflist');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function viewPlayers(User $user)
|
|
|
|
{
|
|
|
|
return $user->can('admin.userlist');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function terminate(User $authUser)
|
|
|
|
{
|
2020-10-21 00:29:50 +00:00
|
|
|
return $authUser->hasRole('admin');
|
2020-06-26 23:32:33 +00:00
|
|
|
}
|
2020-07-16 20:21:28 +00:00
|
|
|
|
|
|
|
public function delete(User $authUser, User $subject)
|
|
|
|
{
|
2020-10-21 00:29:50 +00:00
|
|
|
return $authUser->hasRole('admin') && $authUser->isNot($subject);
|
2020-07-16 20:21:28 +00:00
|
|
|
}
|
2020-06-26 23:32:33 +00:00
|
|
|
}
|