2026-07-08 18:16:46 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Front;
|
|
|
|
|
|
2026-11-05 12:02:36 +01:00
|
|
|
use App\Contracts\Executor;
|
|
|
|
|
use App\Cqs\Queries\Products\GetRelatedProductsQuery;
|
|
|
|
|
use App\Cqs\Queries\Products\GetRelatedProductsQueryInput;
|
|
|
|
|
use App\Cqs\Queries\Recipes\GetFrontRecipesQuery;
|
2026-11-05 16:49:42 +01:00
|
|
|
use App\Dto\RecipeDto;
|
2026-07-08 18:16:46 +02:00
|
|
|
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(
|
2026-11-05 12:02:36 +01:00
|
|
|
private readonly Executor $executor,
|
2026-07-08 18:16:46 +02:00
|
|
|
) {
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-05 12:02:36 +01:00
|
|
|
public function index(
|
|
|
|
|
IndexRecipeRequest $request,
|
|
|
|
|
GetFrontRecipesQuery $getFrontRecipes,
|
|
|
|
|
): Response {
|
|
|
|
|
$paginatedRecipes = $this->executor->execute(
|
|
|
|
|
$getFrontRecipes,
|
|
|
|
|
$request->toGetFrontRecipesQueryInput()
|
2026-07-08 18:16:46 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return Inertia::render('front/Pages/Recipes/Index', [
|
2026-11-05 12:02:36 +01:00
|
|
|
'paginatedRecipes' => $paginatedRecipes,
|
2026-07-08 18:16:46 +02:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-05 12:02:36 +01:00
|
|
|
public function show(
|
2026-11-05 16:49:42 +01:00
|
|
|
RecipeDto $recipe,
|
2026-11-05 12:02:36 +01:00
|
|
|
GetRelatedProductsQuery $getRelatedProducts,
|
|
|
|
|
): Response {
|
|
|
|
|
$relatedProducts = $this->executor->execute(
|
|
|
|
|
$getRelatedProducts,
|
2026-11-05 16:49:42 +01:00
|
|
|
new GetRelatedProductsQueryInput($recipe->getId(), 10)
|
2026-11-05 12:02:36 +01:00
|
|
|
);
|
2026-07-09 15:41:15 +02:00
|
|
|
|
2026-07-08 18:16:46 +02:00
|
|
|
return Inertia::render('front/Pages/Recipes/Show', [
|
2026-07-09 15:41:15 +02:00
|
|
|
'recipe' => $recipe,
|
|
|
|
|
'relatedProducts' => $relatedProducts,
|
2026-07-08 18:16:46 +02:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|