ldc-ovoteam/app/Providers/AuthServiceProvider.php
Jérémy Munsch a1f8e410fe
feat(routes): add duplicate, restore, and force destroy routes for products and recipes
This update introduces new routes for duplicating, restoring, and force deleting products and recipes, enhancing the management capabilities in the application.
2026-09-21 11:43:40 +02:00

41 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Providers;
use App\Models\Product;
use App\Models\Recipe;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
use Uwil\LaravelCommon\Support\InertiaSharedRegistry;
class AuthServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot(): void
{
InertiaSharedRegistry::add('auth.policies', function () {
$localModels = [
Product::class,
Recipe::class,
];
$localPolicies = [];
foreach ($localModels as $model) {
$key = Str::camel(Str::plural(class_basename($model)));
$localPolicies[$key] = [
'viewAny' => Gate::allows('viewAny', $model),
'create' => Gate::allows('create', $model),
'viewTrash' => Gate::allows('viewTrash', $model),
];
}
return $localPolicies;
});
}
}