33 lines
685 B
PHP
33 lines
685 B
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\LegacyInvoice;
|
|
use App\Models\User;
|
|
|
|
class LegacyInvoicePolicy
|
|
{
|
|
public function before(User $user): ?bool
|
|
{
|
|
return $user->is_super_admin ? true : null;
|
|
}
|
|
|
|
public function viewAny(User $user): bool
|
|
{
|
|
return $user->canAccessCustomer();
|
|
}
|
|
|
|
public function view(User $user, LegacyInvoice $legacyInvoice): bool
|
|
{
|
|
if ($user->canAccessAdmin()) {
|
|
return true;
|
|
}
|
|
|
|
return $legacyInvoice->user_id === $user->id;
|
|
}
|
|
|
|
public function downloadPdf(User $user, LegacyInvoice $legacyInvoice): bool
|
|
{
|
|
return $this->view($user, $legacyInvoice);
|
|
}
|
|
}
|