getCategories(); $breedingMethods = $request->getBreedingMethods(); $technologies = $request->getTechnologies(); $businesses = $request->getBusinesses(); $isEgalim = $request->getIsEgalim(); $search = $request->getSearchValue() ?? ''; $categoriesProducts = []; if (count($categories) === 0) { $categories = ! $request->hasFilter() ? [ ProductCategory::OMELETS_AND_DELI_AND_DESSERT_LINES, ProductCategory::HARD_BOILED_EGGS, ] : ProductCategory::cases(); } foreach ($categories as $category) { $result = $this->productDirectory->getCategoryProducts( category: $category, breedingMethods: $breedingMethods, technologies: $technologies, businesses: $businesses, isEgalim: $isEgalim, search: $search, // * No limit on search is volontary, limit is done in front, the creative team did not mind the pagination work. limitPerCategory: -1 ); if ($result !== null) { $categoriesProducts[] = $result; } } return Inertia::render('front/Pages/Products/Index', [ 'categoriesProducts' => $categoriesProducts, ]); } public function show(Product $product): Response { $relatedRecipes = $this->recipeDirectory ->getRelatedRecipes($product->id(), 10); return Inertia::render('front/Pages/Products/Show', [ 'product' => $product, 'relatedRecipes' => $relatedRecipes, ]); } }