osb/app/Models/Policies/InvoicePolicy.php
Deon George 23f57f684e
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 32s
Create Docker Image / Final Docker Image Manifest (push) Successful in 8s
User optimisation and code cleanup
2024-07-05 22:56:02 +10:00

83 lines
1.5 KiB
PHP

<?php
namespace App\Models\Policies;
use Illuminate\Auth\Access\HandlesAuthorization;
use App\Models\{Invoice,User};
class InvoicePolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view the invoice.
*
* @param User $uo
* @param Invoice $io
* @return bool
*/
public function view(User $uo,Invoice $io): bool
{
return $uo->accounts_all->pluck('id')->contains($io->account_id) || $uo->isWholesaler();
}
/**
* Determine whether the user can create services.
*
* @param User $uo
* @return bool
*/
public function create(User $uo): bool
{
return $uo->isWholesaler();
}
/**
* Determine whether the user can update the service.
*
* @param User $uo
* @param Invoice $io
* @return bool
*/
public function update(User $uo,Invoice $io): bool
{
return $uo->isWholesaler();
}
/**
* Determine whether the user can delete the service.
*
* @param User $uo
* @param Invoice $io
* @return bool
*/
public function delete(User $uo,Invoice $io): bool
{
return $uo->isWholesaler();
}
/**
* Determine whether the user can restore the service.
*
* @param User $uo
* @param Invoice $io
* @return bool
*/
public function restore(User $uo,Invoice $io): bool
{
return $uo->isWholesaler();
}
/**
* Determine whether the user can permanently delete the service.
*
* @param User $uo
* @param Invoice $io
* @return bool
*/
public function forceDelete(User $uo,Invoice $io): bool
{
return $uo->isWholesaler();
}
}