Fix Model Policies from matching user_id's and account_id's, and other minor cosmetic fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
namespace App\Models\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
@@ -13,78 +13,78 @@ class UserPolicy
|
||||
/**
|
||||
* Determine whether the user can view the service.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $uo
|
||||
* @param User $o
|
||||
* @return mixed
|
||||
* @return bool
|
||||
*/
|
||||
public function view(User $user, User $o)
|
||||
public function view(User $uo,User $o): bool
|
||||
{
|
||||
// If this is a service for an account managed by a user.
|
||||
return ($user->id == $o->id)
|
||||
return ($uo->id == $o->id)
|
||||
|
||||
// The user is the wholesaler
|
||||
OR $user->isWholesaler()
|
||||
OR $uo->isWholesaler()
|
||||
|
||||
// The user is the reseller
|
||||
OR $user->all_clients()->pluck('id')->search($o->id);
|
||||
OR ($uo->all_clients()->pluck('id')->search($o->id) !== FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create services.
|
||||
*
|
||||
* @param User $user
|
||||
* @return mixed
|
||||
* @param User $uo
|
||||
* @return bool
|
||||
*/
|
||||
public function create(User $user)
|
||||
public function create(User $uo): bool
|
||||
{
|
||||
//
|
||||
return $uo->isWholesaler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the service.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $uo
|
||||
* @param User $o
|
||||
* @return mixed
|
||||
* @return bool
|
||||
*/
|
||||
public function update(User $user, User $o)
|
||||
public function update(User $uo, User $o): bool
|
||||
{
|
||||
//
|
||||
return $uo->isWholesaler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the service.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $uo
|
||||
* @param User $o
|
||||
* @return mixed
|
||||
* @return bool
|
||||
*/
|
||||
public function delete(User $user, User $o)
|
||||
public function delete(User $uo, User $o): bool
|
||||
{
|
||||
//
|
||||
return $uo->isWholesaler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the service.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $uo
|
||||
* @param User $o
|
||||
* @return mixed
|
||||
* @return bool
|
||||
*/
|
||||
public function restore(User $user, User $o)
|
||||
public function restore(User $uo, User $o): bool
|
||||
{
|
||||
//
|
||||
return $uo->isWholesaler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the service.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $uo
|
||||
* @param User $o
|
||||
* @return mixed
|
||||
* @return bool
|
||||
*/
|
||||
public function forceDelete(User $user, User $o)
|
||||
public function forceDelete(User $uo, User $o): bool
|
||||
{
|
||||
//
|
||||
return $uo->isWholesaler();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user