@php $locale = current_locale(); $fallbackTiles = [ [ 'title' => match($locale) { 'en' => 'Hair dryer and styler collection', 'ru' => 'Коллекция фенов и стайлеров', default => 'Fen və stayer kolleksiyası', }, 'image' => 'ht816-new.jpg', 'link' => localized_route('categories.show', 'gozellik-ve-saglamliq'), ], [ 'title' => match($locale) { 'en' => 'Massage devices collection', 'ru' => 'Коллекция массажных устройств', default => 'Massaj cihazları kolleksiyası', }, 'image' => 'c610-s.jpg', 'link' => localized_route('categories.show', 'aksesuarlar'), ], ]; if (!isset($collectionTiles) || $collectionTiles->isEmpty()) { $collectionTiles = collect(); } else { $collectionTiles = $collectionTiles->map(function ($tile) { return [ 'title' => $tile->title, 'image' => $tile->image, 'big_image' => $tile->big_image, 'small_image' => $tile->small_image, 'link' => $tile->link ?: localized_route('products.index'), 'settings' => $tile->settings ?? [], ]; }); } $tileImage = function ($tile, $size = 'image') { if ($size === 'big' && !empty($tile['big_image'])) { return asset('images/' . $tile['big_image']); } if ($size === 'small' && !empty($tile['small_image'])) { return asset('images/' . $tile['small_image']); } if (!empty($tile['image'])) { return asset('images/' . $tile['image']); } return asset('images/placeholder.jpg'); }; $viewCollection = match($locale) { 'en' => 'View collection', 'ru' => 'Смотреть коллекцию', default => 'Kolleksiyaya bax', }; $gridProducts = $gridProducts ?? \App\Models\Product::with('category')->where('is_featured', true)->take(8)->get(); $tile1 = $collectionTiles[0] ?? null; $tile2 = $collectionTiles[1] ?? null; @endphp @if($tile1 && $tile2)
{{-- Collection tile 1 --}} @php $tile1Fit = $tile1['settings']['image_fit'] ?? 'cover'; $tile1Scale = max(1, (float)($tile1['settings']['image_scale'] ?? 1)); @endphp @if($tile1Fit === 'contain') @endif {{ $tile1['title'] }}

{{ $tile1['title'] }}

{{ $viewCollection }}
{{-- Products 1-4: two beside the first collection, two before the second --}} @foreach($gridProducts->slice(0, 4) as $product) @include('partials.product-grid-card', ['product' => $product]) @endforeach {{-- Collection tile 2 --}} @php $tile2Fit = $tile2['settings']['image_fit'] ?? 'cover'; $tile2Scale = max(1, (float)($tile2['settings']['image_scale'] ?? 1)); @endphp @if($tile2Fit === 'contain') @endif {{ $tile2['title'] }}

{{ $tile2['title'] }}

{{ $viewCollection }}
{{-- Products 5-8 --}} @foreach($gridProducts->slice(4, 4) as $product) @include('partials.product-grid-card', ['product' => $product]) @endforeach
@endif