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.
52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Front;
|
|
|
|
use App\Contracts\Executor;
|
|
use App\Cqs\Queries\Products\GetRelatedProductsQuery;
|
|
use App\Cqs\Queries\Products\GetRelatedProductsQueryInput;
|
|
use App\Cqs\Queries\Recipes\GetFrontRecipesQuery;
|
|
use App\Dto\RecipeDto;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Front\Recipes\IndexRecipeRequest;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class RecipeController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly Executor $executor,
|
|
) {
|
|
}
|
|
|
|
public function index(
|
|
IndexRecipeRequest $request,
|
|
GetFrontRecipesQuery $getFrontRecipes,
|
|
): Response {
|
|
$paginatedRecipes = $this->executor->execute(
|
|
$getFrontRecipes,
|
|
$request->toGetFrontRecipesQueryInput()
|
|
);
|
|
|
|
return Inertia::render('front/Pages/Recipes/Index', [
|
|
'paginatedRecipes' => $paginatedRecipes,
|
|
]);
|
|
}
|
|
|
|
public function show(
|
|
RecipeDto $recipe,
|
|
GetRelatedProductsQuery $getRelatedProducts,
|
|
): Response {
|
|
$relatedProducts = $this->executor->execute(
|
|
$getRelatedProducts,
|
|
new GetRelatedProductsQueryInput($recipe->getId(), 10)
|
|
);
|
|
|
|
return Inertia::render('front/Pages/Recipes/Show', [
|
|
'recipe' => $recipe,
|
|
'relatedProducts' => $relatedProducts,
|
|
]);
|
|
}
|
|
}
|