@extends('frontend.layouts.template-base') @section('meta_tags') @include('frontend.layouts.meta-tags', ['title' => 'Health', 'page' => 'health']) @endsection @section('styles') @endsection @section('content') @php $healthSections = collect($healthSections ?? []); $healthBannersByPosition = collect($healthBannersByPosition ?? []); @endphp {{-- ═══════════════════════════════════════════════════════════ STATIC HERO SECTION — DO NOT MODIFY ═══════════════════════════════════════════════════════════ --}}

HEALTHY CHOICES, FRESHLY MADE

Discover nutritious salads, refreshing smoothies, and wholesome meals made with fresh ingredients for your everyday lifestyle.

Explore Offer
Arc Shape
{{-- ═══════════════════════════════════════════════════════════ END STATIC HERO SECTION ═══════════════════════════════════════════════════════════ --}} {{-- ═══════════════════════════════════════════════════════════ DYNAMIC CONTENT — driven entirely by admin panel ═══════════════════════════════════════════════════════════ --}} @if (!($healthLoadError ?? null) && ($healthSections->isNotEmpty() || $healthBannersByPosition->isNotEmpty())) @foreach ($healthSections as $healthSectionIndex => $healthSection) {{-- Banners positioned before this section --}} @foreach ($healthBannersByPosition->get($healthSectionIndex, collect()) as $healthBanner) @if ($healthBanner->banner_image) @include('frontend.components.home-sections.poster', [ 'section' => (object) [ 'banners' => collect([$healthBanner]), 'background_image' => null, ], ]) @else
@endif @endforeach @php $hasProducts = $healthSection->products->isNotEmpty(); $hasSaladBowls = $healthSection->saladBowls->isNotEmpty(); $allTabProducts = $healthSection->tabs->flatMap(fn ($tab) => $tab->products)->unique('id'); $hasTabs = $healthSection->tabs->isNotEmpty() && $allTabProducts->isNotEmpty(); @endphp {{-- Section with tabs — generic products, tabs have content --}} @if ($hasTabs)
{{-- Tab toggle buttons --}}
@foreach ($healthSection->tabs as $tabIndex => $tab) @endforeach
{{-- Section header --}}

{{ $healthSection->name }}

Total Items - {{ $allTabProducts->count() }}
{{-- Tab panes --}} @foreach ($healthSection->tabs as $tabIndex => $tab)
@foreach ($tab->products as $product) @include('frontend.components.health-bowl-card', compact('product')) @endforeach
@endforeach
{{-- Section with Vital Kitchen salad bowls — auto-tabbed by mainCategory --}} @elseif ($hasSaladBowls) @php $vkGroups = $healthSection->saladBowls->groupBy(fn ($b) => $b->mainCategory?->name ?? 'Others'); $vkGroupKeys = $vkGroups->keys(); $hasVkTabs = $vkGroupKeys->count() > 1; @endphp
{{-- Category tab buttons (only when products span multiple categories) --}} @if ($hasVkTabs)
@foreach ($vkGroupKeys as $vkTabIndex => $catName) @endforeach
@endif {{-- Section header --}} @if ($healthSection->name)

{{ $healthSection->name }}

Total Items - {{ $healthSection->saladBowls->count() }}
@endif {{-- Tab panes or flat grid --}} @if ($hasVkTabs) @foreach ($vkGroups as $catIdx => $bowlsInCat)
@foreach ($bowlsInCat as $saladBowl) @include('frontend.components.health-bowl-card', ['product' => $saladBowl, 'isVitalKitchen' => true]) @endforeach
@endforeach @else
@foreach ($healthSection->saladBowls as $saladBowl) @include('frontend.components.health-bowl-card', ['product' => $saladBowl, 'isVitalKitchen' => true]) @endforeach
@endif
{{-- Section without tabs — plain generic product grid --}} @elseif ($hasProducts)
@if ($healthSection->name)

{{ $healthSection->name }}

Total Items - {{ $healthSection->products->count() }}
@endif
@foreach ($healthSection->products as $product) @include('frontend.components.health-bowl-card', compact('product')) @endforeach
@endif @endforeach {{-- Trailing banners after last section --}} @foreach ($healthBannersByPosition->get($healthSections->count(), collect()) as $healthBanner) @if ($healthBanner->banner_image) @include('frontend.components.home-sections.poster', [ 'section' => (object) [ 'banners' => collect([$healthBanner]), 'background_image' => null, ], ]) @else
@endif @endforeach {{-- Cart toast — only needed when products are present --}}
Added to Cart
Cart
0 Items
@endif {{-- end dynamic content --}} @endsection @section('scripts') {{-- Tab switching --}} {{-- Cart / wishlist toast — single source of truth for #cartToastWrap. Previously this page ALSO attached a second click-listener system directly to .btn-add/.qty-btn (removed) that tracked its own fake local quantity in parallel with addItem()/ changeQty() below — both fired on every click, so the displayed number could drift from the real server-side cart. Kept to one system: the real API calls below are the only thing that ever changes quantity, and this toast just reports what they return. --}} {{-- Add-to-cart quantity controls — calls the real cart API (window.CK.api) --}} {{-- Wishlist toggle — calls the real wishlist API (grocery product_id, or Vital Kitchen via type + salad_bowl_id). Guest-accessible, same as add-to-cart. --}} {{-- Pre-fill "already in cart" / "already wishlisted" state on page load, for a logged-in user or a guest with an existing X-Guest-Token. --}} {{-- Static 3-D carousel (hero section — always rendered) --}} @endsection