User optimisation and code cleanup

This commit is contained in:
2024-07-05 22:56:02 +10:00
parent b6b036e06d
commit 326b1dcfc5
12 changed files with 80 additions and 294 deletions

View File

@@ -19,14 +19,7 @@ class InvoicePolicy
*/
public function view(User $uo,Invoice $io): bool
{
// If this is a service for an account managed by a user.
return ($uo->invoices->pluck('id')->search($io->id) !== FALSE)
// The user is the wholesaler
OR $uo->isWholesaler()
// The user has this as one of their accounts
OR $uo->accounts->pluck('id')->contains($io->account_id);
return $uo->accounts_all->pluck('id')->contains($io->account_id) || $uo->isWholesaler();
}
/**