This update introduces new routes for duplicating, restoring, and force deleting products and recipes, enhancing the management capabilities in the application.
41 lines
1.1 KiB
PHP
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;
|
|
});
|
|
}
|
|
}
|