@extends('front.layout.master') @section('meta_tags') @endsection @section('body') @php $lang = $data['lang'] ?? 'en'; $fallback = $data['fallback_local'] ?? 'en'; $tr = function($val) use ($lang, $fallback) { if (is_array($val)) return $val[$lang] ?? $val[$fallback] ?? reset($val); return $val; }; $sliderList = $sliders['sliders'] ?? collect(); $sliderEnable = $sliders['enable'] ?? '1'; $featuredCats = isset($cats) ? $cats->where('featured', '1')->take(12) : collect(); $allCats = isset($cats) ? $cats->take(12) : collect(); $primarySlider = $sliderList->first(); $secondarySliders = $sliderList->skip(1)->take(2); // Per-page widget toggles (managed in /admin/widget/settings) $widgetFlags = collect(\App\Widgetsetting::all())->keyBy('name'); $showCategory = optional($widgetFlags->get('category'))->home == '1'; $showHotdeals = optional($widgetFlags->get('hotdeals'))->home == '1'; $featuredpros = isset($featuredproducts) ? collect($featuredproducts)->filter()->take(10) : collect(); $newProductList = isset($newproduct['all']['products']) ? $newproduct['all']['products'] : (isset($newproduct) && is_iterable($newproduct) ? $newproduct : []); $newpros = collect($newProductList)->filter()->take(10); @endphp {{-- ============= HERO SECTION ============= --}} @if($sliderEnable == '1' && count($sliderList))
{{-- Big hero --}}
@if($primarySlider) @php $sl = (object) $primarySlider; @endphp
{{ $tr($sl->topheading) }}

{{ $tr($sl->heading) }}

{{ $sl->moredescription }}

@endif
{{-- Side promos --}}
@foreach($secondarySliders as $idx => $sl) @php $sl = (object) $sl; $bgs = ['bg-emerald-500', 'bg-fuchsia-600']; $grads = ['from-emerald-700/95 via-emerald-700/70', 'from-fuchsia-800/95 via-fuchsia-700/65']; @endphp
{{-- Image fills the entire card; gradient overlay keeps the left text readable --}}
{{ $tr($sl->topheading) }}

{{ $tr($sl->heading) }}

{{ $tr($sl->buttonname) ?: __('Shop now') }} →
@endforeach {{-- Fill placeholder cards if fewer than 2 secondary sliders --}} @if($secondarySliders->count() < 2) @for($i = $secondarySliders->count(); $i < 2; $i++) @php $bgs = ['bg-emerald-500','bg-fuchsia-600']; @endphp
{{ $i == 0 ? __('Special offer') : __('Trending') }}

{{ $i == 0 ? __('Up to 60% off') : __('New arrivals') }}

{{ __('Shop now') }} →
@endfor @endif
@endif {{-- ============= QUICK BENEFITS ============= --}}
{{ $footer3_widget->shiping ?? __('Free shipping') }}
{{ __('On orders over $50') }}
{{ $footer3_widget->return ?? __('30-day returns') }}
{{ __('Hassle-free policy') }}
{{ $footer3_widget->money ?? __('Secure payments') }}
{{ __('100% protected') }}
{{ $footer3_widget->mobile ?? __('24/7 support') }}
{{ __('Real humans') }}
{{-- ============= SHOP BY CATEGORY ============= --}} @if($showCategory && (count($featuredCats) || count($allCats)))

{{ __('Shop by category') }}

{{ __('Explore products across departments') }}

@foreach(($featuredCats->count() ? $featuredCats : $allCats)->take(6) as $cat)
@if($cat->image && file_exists(public_path() . '/images/category/' . $cat->image)) {{ $cat->title }} @elseif($cat->icon && file_exists(public_path() . '/images/category/' . $cat->icon)) {{ $cat->title }} @else
{{ strtoupper(substr($cat->title, 0, 1)) }}
@endif
{{ $cat->title }}
{{ $cat->subcategory->count() }} {{ __('subcategories') }}
@endforeach
@endif {{-- ============= DEAL OF THE DAY ============= --}} @php try { $flashSale = App\FlashSale::with('products')->where('status', '1')->orderBy('id', 'DESC')->first(); $flashProducts = $flashSale ? $flashSale->products->take(8) : collect(); } catch (\Throwable $e) { $flashSale = null; $flashProducts = collect(); } @endphp @if($flashSale)
{{ __('Deal of the day') }}

{{ $flashSale->title ?? __('Lightning deals, every hour.') }}

{{ __('Up to 70% off — only while stocks last.') }}

{{ __('View all deals') }} →
@foreach($flashProducts as $fp) @php try { $fpName = is_object($fp) && method_exists($fp, 'getTranslations') ? ($fp->getTranslations('name')[$lang] ?? $fp->name) : ($fp->name ?? ''); $fpUrl = is_object($fp) && method_exists($fp, 'getURL') ? '#' : '#'; $fpImg = $fp->image ?? null; } catch (\Throwable $e) { $fpName=''; $fpUrl='#'; $fpImg=null; } @endphp
@if($fpImg) @endif

{{ $fpName }}

@endforeach
@endif {{-- ============= HOT DEALS ============= --}} @if($showHotdeals) @isset($hotdeals) @if($hotdeals->count())

{{ __('Hot Deals') }}

{{ __('Hand-picked products with limited-time discounts') }}

{{ __('See all deals') }} →
@foreach($hotdeals->take(10) as $p) @include('front.partials.product-card', ['p' => $p, 'lang' => $lang]) @endforeach
@endif @endisset @endif {{-- ============= FEATURED PRODUCTS ============= --}} @if(count($featuredpros))

{{ __('Featured Products') }}

{{ __('Top-rated picks just for you') }}

{{ __('See more') }} →
@foreach($featuredpros as $p) @include('front.partials.product-card', ['p' => $p, 'lang' => $lang]) @endforeach
@endif {{-- ============= MID BANNER STRIP ============= --}}
@php $bannerCats = $allCats->take(3); $bannerColors = [ ['bg' => 'bg-indigo-600', 'grad' => 'from-indigo-700', 'btn' => 'text-indigo-700'], ['bg' => 'bg-rose-500', 'grad' => 'from-rose-600', 'btn' => 'text-rose-600'], ['bg' => 'bg-emerald-700', 'grad' => 'from-emerald-800', 'btn' => 'text-emerald-700'], ]; @endphp @foreach($bannerCats as $idx => $bcat) @php $col = $bannerColors[$idx] ?? $bannerColors[0]; @endphp @if($bcat->image && file_exists(public_path() . '/images/category/' . $bcat->image)) @endif
{{ __('Shop') }}

{{ $bcat->title }}

{{ __('Shop now') }} →
@endforeach
{{-- ============= NEW ARRIVALS / TABBED PRODUCTS ============= --}} @if(count($newpros))

{{ __('New Arrivals') }}

{{ __('Latest products from your favorite brands') }}

{{ __('See more') }} →
@foreach($newpros as $p) @include('front.partials.product-card', ['p' => $p, 'lang' => $lang]) @endforeach
@endif {{-- ============= TOP CATEGORY PRODUCTS ============= --}} @if(!empty($topcatgoryproducts)) @foreach($topcatgoryproducts as $cgIdx => $catGroup) @php $catName = is_array($catGroup['category_name']) ? ($catGroup['category_name'][$lang] ?? reset($catGroup['category_name'])) : $catGroup['category_name']; $catProducts = isset($catGroup['products']) ? collect($catGroup['products'])->filter()->take(10) : collect(); @endphp @if(count($catProducts))

{{ __('Best of') }} {{ $catName }}

{{ __('See more') }} →
@foreach($catProducts as $p) @include('front.partials.product-card', ['p' => $p, 'lang' => $lang]) @endforeach
@endif @endforeach @endif {{-- ============= TESTIMONIALS ============= --}} @if(isset($testimonials) && $testimonials->count()) @php $tonePalette = [ ['bg-brand-500', 'fuchsia-500'], ['emerald-500', 'brand-500'], ['rose-500', 'amber-500'], ['indigo-500', 'sky-500'], ['violet-500', 'rose-500'], ['amber-500', 'emerald-500'], ]; $avgRating = $testimonials->avg('rating') ?: 5; @endphp

{{ __('Loved by shoppers worldwide') }}

@for($i=1;$i<=5;$i++){{ $avgRating >= $i - 0.5 ? '★' : '☆' }}@endfor {{ number_format($avgRating, 1) }} / 5 · {{ $testimonials->count() }} {{ __('happy customers') }}
@foreach($testimonials->take(6) as $idx => $t) @php $tone = $tonePalette[$idx % count($tonePalette)]; $rating = max(1, min(5, (int) ($t->rating ?: 5))); $hasImage = $t->image && file_exists(public_path('images/testimonial/' . $t->image)); $initial = strtoupper(mb_substr($t->name ?: 'C', 0, 1)); @endphp
@for($i = 1; $i <= 5; $i++){{ $i <= $rating ? '★' : '☆' }}@endfor

"{{ \Illuminate\Support\Str::limit(strip_tags((string) ($t->des ?? '')), 240) }}"

@if($hasImage) {{ $t->name }} @else
{{ $initial }}
@endif
{{ $t->name }}
{{ $t->post ?: __('Verified buyer') }}
@endforeach
@endif {{-- ============= BLOG SECTION ============= --}} @if(isset($blogs) && count($blogs))

{{ __('Latest from our blog') }}

{{ __('Tips, guides, and inspiration') }}

{{ __('All posts') }} →
@foreach($blogs->take(3) as $blog)
{{ $blog->created_on }} · {{ $blog->read_time ?? '3 min read' }}

{{ is_array($blog->heading) ? ($blog->heading[$lang] ?? (array_values($blog->heading)[0] ?? '')) : $blog->heading }}

{{ \Illuminate\Support\Str::limit($blog->des, 120) }}

@endforeach
@endif @endsection @push('script') @endpush