@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); }; $products = static function ($items, $limit = 6) { return collect($items ?? [])->filter()->take($limit); }; $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 = number_format((float) ($product->default_price ?? $product->price ?? 0), 2); $rate = number_format((float) ($product->rate ?? 4.8), 1); return compact('title', 'productImage', 'price', 'rate'); }; @endphp
@php $heroBanners = collect($mainSlider ?? []); @endphp
@forelse($heroBanners->take(3) as $index => $banner) @empty
@endforelse @php $hero = $heroBanners->first(); @endphp

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

{{ $localized($hero->localized_subtitle ?? $hero->subtitle ?? null, __('ecommerce::ecommerce.home_hero_subtitle')) }}

@lang('ecommerce::ecommerce.shop_now')
@foreach($heroBanners->take(3) as $index => $banner)@endforeach
@foreach(collect($categories ?? []) as $category) {{ $localized($category->title ?? $category->name ?? null, __('ecommerce::ecommerce.home_category_fallback')) }}@endforeach
@foreach(collect($productBanners ?? [])->take(3) as $banner)

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

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

@lang('ecommerce::ecommerce.shop_now')
@endforeach
@php $productSections = [['products' => $bestSellers ?? [], 'title' => __('ecommerce::ecommerce.best_sellers'), 'id' => 'best-sellers'], ['products' => $featuredProducts ?? [], 'title' => __('ecommerce::ecommerce.featured_products'), 'id' => 'featured-products'], ['products' => $newProducts ?? [], 'title' => __('ecommerce::ecommerce.new_products'), 'id' => 'new-products'], ['products' => $exclusiveProducts ?? [], 'title' => __('ecommerce::ecommerce.exclusive_collections'), 'id' => 'exclusive-products'], ['products' => $sectionNewArrivals ?? [], 'title' => __('ecommerce::ecommerce.new_arrival'), 'id' => 'new-arrivals']]; @endphp @foreach($productSections as $section) @if(collect($section['products'])->isNotEmpty())
@foreach($products($section['products'], 8) as $product) @php $card = $renderProduct($product); @endphp @endforeach
@endif @endforeach @if(collect($largeBanner ?? [])->isNotEmpty()) @php $banner = collect($largeBanner)->first(); @endphp

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

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

@lang('ecommerce::ecommerce.shop_now')
@endif
♧
@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 @foreach([['items' => $recentNews ?? [], 'title' => __('ecommerce::ecommerce.recent_news')], ['items' => $clientBrands ?? [], 'title' => __('ecommerce::ecommerce.our_brands')], ['items' => $testimonials ?? [], 'title' => __('ecommerce::ecommerce.testimonials')]] as $extra) @if(collect($extra['items'])->isNotEmpty())

{{ $extra['title'] }}

@foreach(collect($extra['items'])->take(4) as $item)

{{ $localized($item->localized_title ?? $item->title ?? $item['name'] ?? null, $item['name'] ?? '') }}

{{ $localized($item->localized_subtitle ?? $item->subtitle ?? $item['content'] ?? null) }}

@endforeach
@endif @endforeach @endsection @section('scripts') @endsection