@extends('frontend.layouts.template-base') @section('meta_tags') @include('frontend.layouts.meta-tags', ['title' => 'Grocery', 'page' => 'grocery']) @endsection @section('styles') @endsection @section('content') {{-- ═══════════════════════════════════════════════════════════ STATIC HERO SECTION — DO NOT MODIFY ═══════════════════════════════════════════════════════════ --}}
Nuts
Dal
Pickles
Cleaning
{{-- ═══════════════════════════════════════════════════════════ END STATIC HERO SECTION ═══════════════════════════════════════════════════════════ --}} {{-- ═══════════════════════════════════════════════════════════ DYNAMIC CONTENT — driven entirely by admin panel ═══════════════════════════════════════════════════════════ --}} @php $grocerySections = collect($grocerySections ?? []); $groceryBannersByPosition = collect($groceryBannersByPosition ?? []); $positionedGroceryBannerIds = array_flip( $groceryBannersByPosition->flatten(1)->pluck('id')->toArray() ); @endphp @if (!($groceryLoadError ?? null) && ($grocerySections->isNotEmpty() || $groceryBannersByPosition->isNotEmpty())) @foreach ($grocerySections as $grocerySectionIndex => $grocerySection) {{-- Banners positioned before this section --}} @foreach ($groceryBannersByPosition->get($grocerySectionIndex, collect()) as $groceryBanner) @include('frontend.components.home-sections.poster', ['section' => (object) ['banners' => collect([$groceryBanner]), 'background_image' => null]]) @endforeach @php $hasGroups = $grocerySection->groups->isNotEmpty(); $allTabProds = $grocerySection->tabs->flatMap(fn ($t) => $t->products)->unique('id'); $hasTabs = $grocerySection->tabs->isNotEmpty() && $allTabProds->isNotEmpty(); $hasProducts = $grocerySection->products->isNotEmpty(); $sectionBanners = $grocerySection->banners->filter(fn ($b) => !isset($positionedGroceryBannerIds[$b->id])); $hasBannersOnly = !$hasGroups && !$hasTabs && !$hasProducts && $sectionBanners->isNotEmpty(); @endphp {{-- ── BANNER SECTION → 2-up promo row or full-width poster ── --}} @if ($hasBannersOnly) @php // Expand "multiple" type banners: each image (main + additional_images) becomes its own promo slot. // Two separate banner records also produce two slots — same grid, no special casing needed. $promoSlots = collect(); foreach ($sectionBanners as $b) { if (($b->banner_type ?? '') === 'multiple' && !empty($b->additional_images)) { $promoSlots->push(['image' => $b->banner_image, 'banner' => $b]); foreach ($b->additional_images as $extraImg) { $promoSlots->push(['image' => $extraImg, 'banner' => $b]); } } else { $promoSlots->push(['image' => $b->banner_image, 'banner' => $b]); } } @endphp @if ($promoSlots->count() >= 2)
@foreach ($promoSlots->take(2) as $slot) @php $promoBanner = $slot['banner']; $promoBannerImage = $slot['image'] ? \App\Helpers\Helper::get_image($slot['image']) : null; $promoBg = $promoBannerImage ? 'background-image:url(' . json_encode($promoBannerImage) . ')' : ''; $showText = !$promoBannerImage && ($promoBanner->name || $promoBanner->short_description || $promoBanner->button_text); @endphp @endforeach
@foreach ($promoSlots->slice(2) as $extraSlot) @include('frontend.components.home-sections.poster', [ 'section' => (object) ['banners' => collect([$extraSlot['banner']]), 'background_image' => null], ]) @endforeach @else @foreach ($sectionBanners as $groceryBanner) @include('frontend.components.home-sections.poster', [ 'section' => (object) ['banners' => collect([$groceryBanner]), 'background_image' => null], ]) @endforeach @endif {{-- ── GROUPS → Category cards grid ── --}} @elseif ($hasGroups)

{{ $grocerySection->name }}

@foreach ($grocerySection->groups as $group) @endforeach
{{-- ── TABS → Tab-based product section ── --}} @elseif ($hasTabs)

{{ $grocerySection->name }}

@foreach ($grocerySection->tabs as $tabIdx => $tab) @endforeach
@foreach ($grocerySection->tabs as $tabIdx => $tab)
@foreach ($tab->products->take(6) as $product) @include('frontend.components.home-product-card', compact('product')) @endforeach
@endforeach
{{-- ── PRODUCTS → Regular product grid ── --}} @elseif ($hasProducts) @include('frontend.components.fresh-product-section', [ 'products' => $grocerySection->products, 'title' => $grocerySection->name, 'section' => $grocerySection, 'sectionClass' => 'grocery-sec', 'seeAllUrl' => route('frontend.category', array_filter(['category_id' => $groceryCategory?->id])), ]) @endif @endforeach {{-- Banners after the last section --}} @foreach ($groceryBannersByPosition->get($grocerySections->count(), collect()) as $groceryBanner) @include('frontend.components.home-sections.poster', ['section' => (object) ['banners' => collect([$groceryBanner]), 'background_image' => null]]) @endforeach @elseif ($groceryLoadError ?? null) {{--
{{ $groceryLoadError }}
--}} @endif {{-- end dynamic content --}} @endsection @section('scripts') {{-- Hero swiper --}} {{-- Dynamic tab switching (scoped per section, with card entrance animation) --}} @endsection