62 lines
2.5 KiB
PHP
62 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Enums\NoticeTypeEnum;
|
|
use App\Models\Brand;
|
|
use App\Models\InvoiceCompany;
|
|
use App\Models\InvoicePackage;
|
|
use App\Models\Notice;
|
|
use App\Models\Site;
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Uwil\LaravelBackend\Support\UserRoleRegistry;
|
|
use Uwil\LaravelCommon\Support\InertiaSharedRegistry;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Bootstrap any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
Route::bind('user', fn($value) => User::withTrashed()->findOrFail($value));
|
|
|
|
// Set new role for users.
|
|
UserRoleRegistry::add(3, 'project-manager', trans('enums.user-role.project-manager'));
|
|
UserRoleRegistry::add(4, 'developper', trans('enums.user-role.developper'));
|
|
UserRoleRegistry::add(5, 'client', trans('enums.user-role.client'));
|
|
|
|
// Set new props to share.
|
|
InertiaSharedRegistry::add('noticeTypeEnum', fn () => NoticeTypeEnum::toArray());
|
|
InertiaSharedRegistry::add('auth.policies.notices', fn () => [
|
|
'viewAny' => Gate::allows('viewAny', Notice::class),
|
|
'viewTrash' => Gate::allows('viewTrash', Notice::class),
|
|
'create' => Gate::allows('create', Notice::class),
|
|
]);
|
|
InertiaSharedRegistry::add('auth.policies.invoicePackages', fn () => [
|
|
'viewAny' => Gate::allows('viewAny', InvoicePackage::class),
|
|
'viewTrash' => Gate::allows('viewTrash', InvoicePackage::class),
|
|
'create' => Gate::allows('create', InvoicePackage::class),
|
|
]);
|
|
InertiaSharedRegistry::add('auth.policies.invoiceCompanies', fn () => [
|
|
'viewAny' => Gate::allows('viewAny', InvoiceCompany::class),
|
|
'viewTrash' => Gate::allows('viewTrash', InvoiceCompany::class),
|
|
'create' => Gate::allows('create', InvoiceCompany::class),
|
|
]);
|
|
InertiaSharedRegistry::add('auth.policies.sites', fn () => [
|
|
'viewAny' => Gate::allows('viewAny', Site::class),
|
|
'viewTrash' => Gate::allows('viewTrash', Site::class),
|
|
'create' => Gate::allows('create', Site::class),
|
|
]);
|
|
InertiaSharedRegistry::add('auth.policies.brands', fn () => [
|
|
'viewAny' => Gate::allows('viewAny', Brand::class),
|
|
'viewTrash' => Gate::allows('viewTrash', Brand::class),
|
|
'create' => Gate::allows('create', Brand::class),
|
|
]);
|
|
}
|
|
}
|