2019-07-04 04:55:05 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models\Policies;
|
|
|
|
|
|
|
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
|
|
|
|
2021-06-29 03:18:52 +00:00
|
|
|
use App\Models\{Invoice,User};
|
2019-07-04 04:55:05 +00:00
|
|
|
|
|
|
|
class InvoicePolicy
|
|
|
|
{
|
|
|
|
use HandlesAuthorization;
|
|
|
|
|
|
|
|
/**
|
2022-04-22 06:35:01 +00:00
|
|
|
* Determine whether the user can view the invoice.
|
2019-07-04 04:55:05 +00:00
|
|
|
*
|
2021-09-29 06:20:22 +00:00
|
|
|
* @param User $uo
|
|
|
|
* @param Invoice $io
|
|
|
|
* @return bool
|
2019-07-04 04:55:05 +00:00
|
|
|
*/
|
2021-09-29 06:20:22 +00:00
|
|
|
public function view(User $uo,Invoice $io): bool
|
2019-07-04 04:55:05 +00:00
|
|
|
{
|
2024-07-05 12:56:02 +00:00
|
|
|
return $uo->accounts_all->pluck('id')->contains($io->account_id) || $uo->isWholesaler();
|
2019-07-04 04:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can create services.
|
|
|
|
*
|
2021-09-29 06:20:22 +00:00
|
|
|
* @param User $uo
|
|
|
|
* @return bool
|
2019-07-04 04:55:05 +00:00
|
|
|
*/
|
2021-09-29 06:20:22 +00:00
|
|
|
public function create(User $uo): bool
|
2019-07-04 04:55:05 +00:00
|
|
|
{
|
2021-09-29 06:20:22 +00:00
|
|
|
return $uo->isWholesaler();
|
2019-07-04 04:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can update the service.
|
|
|
|
*
|
2021-09-29 06:20:22 +00:00
|
|
|
* @param User $uo
|
|
|
|
* @param Invoice $io
|
|
|
|
* @return bool
|
2019-07-04 04:55:05 +00:00
|
|
|
*/
|
2021-09-29 06:20:22 +00:00
|
|
|
public function update(User $uo,Invoice $io): bool
|
2019-07-04 04:55:05 +00:00
|
|
|
{
|
2021-09-29 06:20:22 +00:00
|
|
|
return $uo->isWholesaler();
|
2019-07-04 04:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can delete the service.
|
|
|
|
*
|
2021-09-29 06:20:22 +00:00
|
|
|
* @param User $uo
|
|
|
|
* @param Invoice $io
|
|
|
|
* @return bool
|
2019-07-04 04:55:05 +00:00
|
|
|
*/
|
2021-09-29 06:20:22 +00:00
|
|
|
public function delete(User $uo,Invoice $io): bool
|
2019-07-04 04:55:05 +00:00
|
|
|
{
|
2021-09-29 06:20:22 +00:00
|
|
|
return $uo->isWholesaler();
|
2019-07-04 04:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can restore the service.
|
|
|
|
*
|
2021-09-29 06:20:22 +00:00
|
|
|
* @param User $uo
|
|
|
|
* @param Invoice $io
|
|
|
|
* @return bool
|
2019-07-04 04:55:05 +00:00
|
|
|
*/
|
2021-09-29 06:20:22 +00:00
|
|
|
public function restore(User $uo,Invoice $io): bool
|
2019-07-04 04:55:05 +00:00
|
|
|
{
|
2021-09-29 06:20:22 +00:00
|
|
|
return $uo->isWholesaler();
|
2019-07-04 04:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can permanently delete the service.
|
|
|
|
*
|
2021-09-29 06:20:22 +00:00
|
|
|
* @param User $uo
|
|
|
|
* @param Invoice $io
|
|
|
|
* @return bool
|
2019-07-04 04:55:05 +00:00
|
|
|
*/
|
2021-09-29 06:20:22 +00:00
|
|
|
public function forceDelete(User $uo,Invoice $io): bool
|
2019-07-04 04:55:05 +00:00
|
|
|
{
|
2021-09-29 06:20:22 +00:00
|
|
|
return $uo->isWholesaler();
|
2019-07-04 04:55:05 +00:00
|
|
|
}
|
|
|
|
}
|