User optimisation and code cleanup
This commit is contained in:
@@ -15,11 +15,11 @@ class UserPolicy
|
||||
*
|
||||
* @param User $uo
|
||||
* @param string $ability
|
||||
* @return bool|null
|
||||
* @return null|bool
|
||||
*/
|
||||
public function before(User $uo,string $ability): bool
|
||||
public function before(User $uo,string $ability): bool|NULL
|
||||
{
|
||||
return $uo->isWholesaler() ?: FALSE;
|
||||
return $uo->isWholesaler() ?: NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,9 +44,6 @@ class UserPolicy
|
||||
public function view(User $uo,User $o): bool
|
||||
{
|
||||
// If this is a service for an account managed by a user.
|
||||
return ($uo->id == $o->id)
|
||||
|
||||
// The user has this as one of their accounts
|
||||
OR $uo->accounts->pluck('user')->pluck('id')->unique()->contains($o->id);
|
||||
return ($uo->id == $o->id) || $uo->accounts_all->pluck('user_id')->contains($o->id) || $uo->isWholesaler();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user