Updated ProductPolicy and RecipePolicy to accept ProductDto in addition to Product. This change enhances the flexibility of the policies by allowing DTOs to be used for authorization checks. refactor(provider): simplify service provider bindings Refactored AppServiceProvider to simplify the binding of ProductDirectory and RecipeDirectory. Removed unnecessary dependencies and improved clarity. feat(route): update route bindings for front-end Changed route bindings for products and recipes to use frontProduct and frontRecipe. This improves clarity and consistency in route handling. fix(breadcrumbs): update breadcrumb checks for DTOs Updated breadcrumb generation to check for ProductDto and RecipeDto instead of their model counterparts. This ensures breadcrumbs function correctly with the new DTO structure. refactor(types): remove FilePath type and update schemas Removed the FilePath type definition and updated related schemas to use string directly. This simplifies type handling for file paths. style(entities): standardize naming conventions Updated naming conventions in Product and Recipe entities to use snake_case for consistency across the codebase. feat(frontend): update product and recipe pages for new DTO structure Modified front-end components to accommodate changes in the product and recipe data structures, ensuring compatibility with the new DTOs.
48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Dto\ProductDto;
|
|
use App\Dto\RecipeDto;
|
|
use App\Models\Product;
|
|
use App\Models\Recipe;
|
|
use App\Policies\ProductPolicy;
|
|
use App\Policies\RecipePolicy;
|
|
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
|
|
{
|
|
Gate::policy(ProductDto::class, ProductPolicy::class);
|
|
Gate::policy(RecipeDto::class, RecipePolicy::class);
|
|
|
|
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;
|
|
});
|
|
}
|
|
}
|