Files
InvoiceShelf/app/Domains/Sales/Policies/RecurringInvoicePolicy.php
T
Darko Gjorgjijoski 5ef7804e60 refactor: adopt modular domain architecture (#747)
* refactor: stabilize model identities for domain migration

* refactor: extract module platform context

* refactor: assign models to domain contexts

* refactor: extract ai platform context

* refactor: extract storage platform context

* refactor: extract mail platform context

* refactor: extract pdf platform context

* refactor: extract operations platform context

* refactor: move installation into operations platform

* refactor: extract money domain context

* refactor: extract taxation domain context

* refactor: extract catalog domain context

* refactor: extract metadata domain context

* refactor: extract reporting domain context

* refactor: extract purchases domain context

* refactor: extract receivables domain context

* refactor: extract accounts domain context

* refactor: complete reporting statement boundary

* refactor: extract contacts domain context

* refactor: extract sales domain context

* refactor: remove legacy application layers

* fix: migrate legacy bouncer role identities
2026-08-05 17:40:03 +02:00

127 lines
3.1 KiB
PHP

<?php
namespace App\Domains\Sales\Policies;
use App\Domains\Accounts\Models\User;
use App\Domains\Sales\Models\RecurringInvoice;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Silber\Bouncer\BouncerFacade;
class RecurringInvoicePolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*
* @return Response|bool
*/
public function viewAny(User $user): bool
{
if (BouncerFacade::can('view-recurring-invoice', RecurringInvoice::class)) {
return true;
}
return false;
}
/**
* Determine whether the user can view the model.
*
* @return Response|bool
*/
public function view(User $user, RecurringInvoice $recurringInvoice): bool
{
if (BouncerFacade::can('view-recurring-invoice', $recurringInvoice) && $user->hasCompany($recurringInvoice->company_id)) {
return true;
}
return false;
}
/**
* Determine whether the user can create models.
*
* @return Response|bool
*/
public function create(User $user): bool
{
if (BouncerFacade::can('create-recurring-invoice', RecurringInvoice::class)) {
return true;
}
return false;
}
/**
* Determine whether the user can update the model.
*
* @return Response|bool
*/
public function update(User $user, RecurringInvoice $recurringInvoice): bool
{
if (BouncerFacade::can('edit-recurring-invoice', $recurringInvoice) && $user->hasCompany($recurringInvoice->company_id)) {
return true;
}
return false;
}
/**
* Determine whether the user can delete the model.
*
* @return Response|bool
*/
public function delete(User $user, RecurringInvoice $recurringInvoice): bool
{
if (BouncerFacade::can('delete-recurring-invoice', $recurringInvoice) && $user->hasCompany($recurringInvoice->company_id)) {
return true;
}
return false;
}
/**
* Determine whether the user can restore the model.
*
* @return Response|bool
*/
public function restore(User $user, RecurringInvoice $recurringInvoice): bool
{
if (BouncerFacade::can('delete-recurring-invoice', $recurringInvoice) && $user->hasCompany($recurringInvoice->company_id)) {
return true;
}
return false;
}
/**
* Determine whether the user can permanently delete the model.
*
* @return Response|bool
*/
public function forceDelete(User $user, RecurringInvoice $recurringInvoice): bool
{
if (BouncerFacade::can('delete-recurring-invoice', $recurringInvoice) && $user->hasCompany($recurringInvoice->company_id)) {
return true;
}
return false;
}
/**
* Determine whether the user can delete models.
*
* @return mixed
*/
public function deleteMultiple(User $user)
{
if (BouncerFacade::can('delete-recurring-invoice', RecurringInvoice::class)) {
return true;
}
return false;
}
}