@extends('ecommerce::layout.store-layout') {{-- @section bodies are evaluated BEFORE the parent layout runs, so anything the sections need must be resolved here, not in store-layout. --}} @php $currentLocale = $currentLocale ?? app()->getLocale(); $isRTL = $isRTL ?? in_array($currentLocale, ['ar', 'he', 'fa', 'ur'], true); @endphp @section('title', __('ecommerce::ecommerce.home')) @section('active-nav', 'home') @section('page-styles') @endsection @section('content') @php $localized = static function ($value, $fallback = '') use ($currentLocale) { if (is_array($value)) { return $value[$currentLocale] ?? ($value['en'] ?? (reset($value) ?? $fallback)); } return $value ?: $fallback; }; $image = static function ($value, $fallback = 'assets/ecommerce/images/slider/4.webp') { return $value ?: asset($fallback); }; $bannerBackgroundStyle = static function ($banner, $fallback = 'assets/ecommerce/images/slider/4.webp') use ($image) { $desktop = $image($banner->desktop_image_url ?? ($banner->image_desktop ?? null), $fallback); $tablet = $image($banner->tablet_image_url ?? null, $desktop); $mobile = $image($banner->mobile_image_url ?? null, $desktop); return "--ad-image-desktop:url('{$desktop}');--ad-image-tablet:url('{$tablet}');--ad-image-mobile:url('{$mobile}')"; }; $products = static function ($items) { return collect($items ?? []) ->filter() ->values(); }; $renderProduct = static function ($product) use ($image, $localized) { $title = $localized($product->title ?? null, __('ecommerce::ecommerce.product_label')); $productImage = $image($product->image_path ?? ($product->image ?? null)); $price = (float) ($product->default_price ?? ($product->price ?? 0)); return compact('title', 'productImage', 'price'); }; @endphp
@php $heroSlides = collect($mainSlider ?? []) ->map(function ($slide) { if (is_array($slide)) { $slide = (object) $slide; } $defaultImg = asset('assets/ecommerce/images/slider/4.webp'); $resolveImage = function (string $device) use ($slide) { $image = method_exists($slide, 'getImageUrl') ? $slide->getImageUrl($device) : ($slide->{$device . '_image_url'} ?? data_get($slide, "content.images.{$device}") ?? ($slide->{'image_' . $device} ?? null)); if ($image && !filter_var($image, FILTER_VALIDATE_URL) && !str_starts_with($image, '/') && file_exists(public_path($image))) { $image = asset($image); } return $image ?: null; }; $slide->resolved_images = [ 'desktop' => $resolveImage('desktop'), 'tablet' => $resolveImage('tablet'), 'mobile' => $resolveImage('mobile'), ]; $slide->resolved_image = $slide->resolved_images['desktop'] ?: $slide->resolved_images['tablet'] ?: $slide->resolved_images['mobile'] ?: $defaultImg; return $slide; }) ->values(); if ($heroSlides->isEmpty()) { $heroSlides = collect([ (object) [ 'localized_title' => __('ecommerce::ecommerce.home_hero_title', [], $currentLocale), 'localized_subtitle' => __('ecommerce::ecommerce.home_hero_subtitle', [], $currentLocale), 'click_url' => '#products', 'resolved_image' => asset('assets/ecommerce/images/slider/4.webp'), ], ]); } @endphp @if ($heroSlides->isNotEmpty())
@foreach ($heroSlides as $idx => $slide) @php $slideCount = $heroSlides->count(); $galleryIndexes = array_values( array_unique([$idx, ($idx + 1) % $slideCount, ($idx + 2) % $slideCount]), ); $buttonText = data_get($slide, "click_action.button_text.{$currentLocale}"); @endphp

{{ $slide->localized_title ?: __('ecommerce::ecommerce.home_hero_title', [], $currentLocale) }}

{{ $slide->localized_subtitle ?: __('ecommerce::ecommerce.home_hero_subtitle', [], $currentLocale) }}

@if($slide->click_url) target ?? '_self') === '_blank') rel="noopener noreferrer" @endif> {{ $buttonText ?: __('ecommerce::ecommerce.shop_now', [], $currentLocale) }} @endif
@foreach ($heroSlides as $dotIdx => $banner) @endforeach
@endforeach
@endif
@foreach (collect($categories ?? []) as $category) @if ($category->image) @else @endif {{ $localized($category->title ?? ($category->name ?? null), __('ecommerce::ecommerce.home_category_fallback')) }} @endforeach
@foreach (collect($productBanners ?? [])->take(3) as $banner) @php $bannerButtonText = data_get($banner, "click_action.button_text.{$currentLocale}"); @endphp @if($banner->click_url) target ?? '_self') === '_blank') rel="noopener noreferrer" @endif style="{{ $bannerBackgroundStyle($banner) }}"> @else @endif @endforeach
@php $productSections = collect([ [ 'products' => $bestSellers ?? [], 'title' => __('ecommerce::ecommerce.best_sellers'), 'id' => 'best-sellers', 'collection' => 'best-sellers', ], [ 'products' => $featuredProducts ?? [], 'title' => __('ecommerce::ecommerce.featured_products'), 'id' => 'featured-products', 'collection' => 'featured-products', ], [ 'products' => $newProducts ?? [], 'title' => __('ecommerce::ecommerce.new_products'), 'id' => 'new-products', 'collection' => 'new-products', ], [ 'products' => $exclusiveProducts ?? [], 'title' => __('ecommerce::ecommerce.exclusive_collections'), 'id' => 'exclusive-products', 'collection' => 'exclusive-products', ], ]) ->filter(fn($section) => collect($section['products'])->isNotEmpty()) ->values(); $midProductBanner = collect($largeBanner ?? [])->first(); $bannerAfterSection = min(2, $productSections->count()); @endphp @foreach ($productSections as $section)
@php $sectionSlides = $products($section['products'])->chunk(6)->values(); @endphp
@if ($midProductBanner && $loop->iteration === $bannerAfterSection)
@if($midProductBanner->click_url) target ?? '_self') === '_blank') rel="noopener noreferrer" @endif aria-label="{{ $localized($midProductBanner->localized_title ?? ($midProductBanner->title ?? null), __('ecommerce::ecommerce.home_banner2_fallback')) }}"> @endif

{{ $localized($midProductBanner->localized_subtitle ?? ($midProductBanner->subtitle ?? null)) }}

{{ $localized($midProductBanner->localized_title ?? ($midProductBanner->title ?? null), __('ecommerce::ecommerce.home_banner2_fallback')) }}

@if($midProductBanner->click_url) target ?? '_self') === '_blank') rel="noopener noreferrer" @endif> {{ data_get($midProductBanner, "click_action.button_text.{$currentLocale}") ?: __('ecommerce::ecommerce.shop_now', [], $currentLocale) }} @endif
@endif @endforeach
♧
@lang('ecommerce::ecommerce.home_feature_fast_title')@lang('ecommerce::ecommerce.home_feature_fast_desc')
♢
@lang('ecommerce::ecommerce.home_feature_secure_title')@lang('ecommerce::ecommerce.home_feature_secure_desc')
⚙
@lang('ecommerce::ecommerce.home_feature_quality_title')@lang('ecommerce::ecommerce.home_feature_quality_desc')
♧
@lang('ecommerce::ecommerce.home_feature_support_title')@lang('ecommerce::ecommerce.home_feature_support_desc')
@if (collect($merchantSlider ?? [])->isNotEmpty())

@lang('ecommerce::ecommerce.merchants')

@lang('ecommerce::ecommerce.view_all') >
@foreach ($merchantSlider as $merchant) @php $merchantName = $localized( $merchant->company_name ?? ($merchant->name ?? null), __('ecommerce::ecommerce.home_merchant_fallback'), ); $branch = collect($merchant->branches ?? [])->first(); $cover = $branch->cover ?? ($branch->cover_image ?? null); @endphp
@if (($merchant->status ?? null) === 'active') @lang('ecommerce::ecommerce.verified_seller') ✓ @endif

{{ $merchantName }}

{{ number_format((float) ($merchant->rate ?? 1), 1) }} ★ ({{ $merchant->reviews_count ?? 0 }})
@foreach (collect($merchant->productCategories ?? [])->take(3) as $category) # {{ $localized($category->title ?? ($category->name ?? null)) }} @endforeach
{{ $merchant->branches_count ?? 0 }} @lang('ecommerce::ecommerce.branches') {{ $merchant->items_count ?? 0 }} @lang('ecommerce::ecommerce.items_label')
@lang('ecommerce::ecommerce.visit_store') >
@endforeach
@endif @if (collect($recentNews ?? [])->isNotEmpty())

{{ __('ecommerce::ecommerce.recent_news') }}

@foreach (collect($recentNews)->take(3) as $news) @php $newsTitle = $localized($news->localized_title ?? ($news->title ?? null), ''); $newsSubtitle = $localized($news->localized_subtitle ?? ($news->subtitle ?? null), ''); $newsImage = $news->desktop_image_url ?? null; $newsHref = $news->click_url; @endphp @if($newsHref) target ?? '_self') === '_blank') rel="noopener noreferrer" @endif> @else @endif @endforeach
@endif @if (collect($clientBrands ?? [])->isNotEmpty())

{{ __('ecommerce::ecommerce.our_brands') }}

@foreach (collect($clientBrands)->take(5) as $brand) @php $brandTitle = $localized($brand->localized_title ?? ($brand->title ?? null), ''); $brandLogo = $brand->desktop_image_url ?? null; @endphp @if($brand->click_url) target ?? '_self') === '_blank') rel="noopener noreferrer" @endif> @else @endif @endforeach
@endif @if (collect($testimonials ?? [])->isNotEmpty())

{{ __('ecommerce::ecommerce.testimonials') }}

@foreach ($testimonials as $testimonial)
@if (filled($testimonial['image'] ?? null)) {{ $testimonial['name'] ?? '' }} @endif

{{ $testimonial['name'] ?? '' }}

@if (filled($testimonial['position'] ?? null))
{{ $testimonial['position'] }}
@endif

{{ $testimonial['content'] ?? '' }}

@endforeach
@if (count($testimonials) > 1)
@foreach ($testimonials as $index => $testimonial) @endforeach
@endif
@endif

{{ __('ecommerce::ecommerce.testimonial_form_title') }}

@if (session('testimonial_submitted'))
{{ __('ecommerce::ecommerce.testimonial_submitted') }}
@endif

{{ __('ecommerce::ecommerce.testimonial_form_description') }}

@csrf @error('name') {{ $message }} @enderror @error('position') {{ $message }} @enderror @error('content') {{ $message }} @enderror
@endsection @section('scripts') @endsection