@php // Cache le header 30 min — toutes les requêtes en un seul bloc mis en cache $headerData = cache()->remember('header_navigation', 1800, function () { $menu = \App\Models\Menu::where('location','primary') ->with(['items.children'])->first(); $soinsItems = $menu ? $menu->items->filter(fn($i) => !in_array($i->id, [19, 40])) : collect(); // Catégories produits pour le méga-menu boutique // Une seule requête avec withCount au lieu de N exists() $allCategories = \App\Models\ProductCategory::whereNull('parent_id') ->where('slug', '!=', 'non-classe') ->with('children') ->get(); $allCatIds = $allCategories->flatMap(fn($cat) => $cat->children->pluck('id')->push($cat->id)); $activeCatIds = \App\Models\Product::where('is_active', true) ->whereIn('category_id', $allCatIds) ->distinct() ->pluck('category_id'); $boutiqueCategories = $allCategories->filter(function($cat) use ($activeCatIds) { $ids = $cat->children->pluck('id')->push($cat->id); return $ids->intersect($activeCatIds)->isNotEmpty(); }); // Un produit mis en avant pour l'encart boutique (hors bijoux) $bijouIds = \App\Models\ProductCategory::where('slug', 'bijoux') ->orWhere('parent_id', \App\Models\ProductCategory::where('slug', 'bijoux')->value('id')) ->pluck('id')->toArray(); $featuredProduct = \App\Models\Product::whereNotNull('featured_image_id') ->where('is_active', true) ->where('is_featured', true) ->whereNotIn('category_id', $bijouIds) ->with('featuredImage') ->first() ?? \App\Models\Product::whereNotNull('featured_image_id') ->where('is_active', true) ->whereNotIn('category_id', $bijouIds) ->with('featuredImage') ->inRandomOrder() ->first(); return compact('soinsItems', 'boutiqueCategories', 'featuredProduct'); }); $soinsItems = $headerData['soinsItems']; $boutiqueCategories = $headerData['boutiqueCategories']; $featuredProduct = $headerData['featuredProduct']; $coffretCategory = $boutiqueCategories->firstWhere('slug', 'coffrets-cadeaux'); $boutiqueGrid = $boutiqueCategories->reject(fn($c) => $c->slug === 'coffrets-cadeaux'); $soinsWithChildren = $soinsItems->filter(fn($i) => $i->children->isNotEmpty()); $soinsSolo = $soinsItems->filter(fn($i) => $i->children->isEmpty()); @endphp
{{-- Logo --}} Institut Corps à Coeur {{-- Nav desktop --}} {{-- Actions --}}
{{-- RDV (desktop) --}} {{-- Compte --}} @auth @else @endauth {{-- Panier --}}
{{-- Burger mobile --}}
{{-- MÉGA-MENU "Nos Soins" (pleine largeur) --}}
{{-- Colonne 1 : Items sans enfants regroupés --}}

Nos prestations

{{-- Colonnes 2-4 : Items avec enfants --}} @foreach($soinsWithChildren as $item)
{{ $item->label }}
@endforeach
{{-- Encarts CTA --}}

Envie de prendre soin de vous ?

Réservez votre créneau en ligne en quelques clics

Prendre rendez-vous →

Votre bilan minceur personnalisé

Faites le point sur vos objectifs avec notre équipe

Commencer →
{{-- MÉGA-MENU "Boutique" (pleine largeur) --}}
{{-- Grille de catégories (toujours à gauche) --}}
@foreach($boutiqueGrid as $cat)
{{ $cat->name }} @if($cat->children->isNotEmpty()) @endif
@endforeach
{{-- Colonne de droite : produit + diagnostic --}}
@if($featuredProduct) @endif
{{-- Encarts Coffrets + Diagnostic côte à côte --}}
{{-- Encart Coffrets Cadeaux --}} @if($coffretCategory)

Une idée cadeau qui fait plaisir

Nos coffrets beauté pour toutes les occasions →

@endif {{-- Encart Diagnostic de peau --}}

Diagnostic de peau

Trouvez vos soins idéaux →

{{-- Nav mobile --}}
{{-- Nos Soins (accordéon) --}}
@foreach($soinsItems as $item) {{ $item->label }} @foreach($item->children->sortBy('sort_order') as $child) {{ $child->label }} @endforeach @endforeach
{{-- Boutique (accordéon avec sous-catégories) --}}
Tous les produits @foreach($boutiqueCategories as $cat) {{ $cat->name }} @foreach($cat->children as $sub) {{ $sub->name }} @endforeach @endforeach
{{-- Liens directs --}} Diagnostic de peau {{-- Compte + RDV --}}