Move User model to Models/
This commit is contained in:
90
app/Models/Policies/UserPolicy.php
Normal file
90
app/Models/Policies/UserPolicy.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class UserPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the service.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $o
|
||||
* @return mixed
|
||||
*/
|
||||
public function view(User $user, User $o)
|
||||
{
|
||||
// If this is a service for an account managed by a user.
|
||||
return ($user->id == $o->id)
|
||||
|
||||
// The user is the wholesaler
|
||||
OR $user->isWholesaler()
|
||||
|
||||
// The user is the reseller
|
||||
OR $user->all_clients()->pluck('id')->search($o->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create services.
|
||||
*
|
||||
* @param User $user
|
||||
* @return mixed
|
||||
*/
|
||||
public function create(User $user)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the service.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $o
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(User $user, User $o)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the service.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $o
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete(User $user, User $o)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the service.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $o
|
||||
* @return mixed
|
||||
*/
|
||||
public function restore(User $user, User $o)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the service.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $o
|
||||
* @return mixed
|
||||
*/
|
||||
public function forceDelete(User $user, User $o)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user