ultimatepos/Modules/SupplyChain/Http/Controllers/Concerns/AuthorizesSupplyChain.php

18 lines
428 B
PHP

<?php
namespace Modules\SupplyChain\Http\Controllers\Concerns;
trait AuthorizesSupplyChain
{
protected function authorizeSupplyChain(?string $permission = null): void
{
if (! auth()->user()->can('supplychain.access')) {
abort(403, 'Unauthorized action.');
}
if ($permission && ! auth()->user()->can($permission)) {
abort(403, 'Unauthorized action.');
}
}
}