@extends('layout.frontend.master') @section('meta-title', 'Category - LEREVE') @push('asset-top') @endpush @section('content')
{{-- /gallery/category/ --}} inner banner
@if(count($products) > 0)
@php $sortedProducts = []; $otherProducts = []; // First, categorize products based on 'location' foreach($products as $product) { if (!empty($product->location) && $product->location > 0) { $sortedProducts[$product->location] = $product; } else { $otherProducts[] = $product; } } // Sort products based on 'location' ksort($sortedProducts); // Take the first 9 sorted products $finalProducts = array_slice($sortedProducts, 0, 9); $remainingSlots = 9 - count($finalProducts); // If there are slots remaining, fill them with products that don't have a 'location' if ($remainingSlots > 0) { $finalProducts = array_merge($finalProducts, array_slice($otherProducts, 0, $remainingSlots)); } // Store any remaining products (both sorted and unsorted) for additional display $moreProducts = array_merge(array_slice($sortedProducts, 9), array_slice($otherProducts, $remainingSlots)); @endphp {{-- Loop through final products and display them --}} @foreach($products as $key => $product)
@if($product->new)
{{__('New')}}
@endif @if(!empty($product->single_sale_price) && $product->single_price != null && $product->single_price > 0) @php $percent = ceil((($product->single_price - $product->single_sale_price) / $product->single_price) * 100); @endphp @if($percent!=0)
{{ $percent }}% {{ __('OFF') }}
@endif @endif @php $quantity = json_decode($product->quantity, true); $quantity = $product->single_quantity; @endphp {{-- @if(is_null($quantity) || !array_key_exists('Select', $quantity) || is_null($quantity['Select']))
{{__('Out Of Stock')}}
@endif --}} @php $isOutOfStock = true; /*if (!is_null($quantity)) { foreach ($quantity as $key => $value) { if ($value > 0) { $isOutOfStock = false; break; // No need to check further if one of the quantities is available } } } */ if($quantity){ $isOutOfStock = false; } @endphp @if($isOutOfStock)
{{__('Out Of Stock')}}
@endif product

{{ (app()->getLocale() == 'en') ? $product->name_en : $product->name_ar }}

@if($product->single_sale_price && $product->single_sale_price!=$product->single_price)
{{ $product->single_sale_price }} {{ __('KWD') }} {{ $product->single_price }} {{ __('KWD') }}
@else
{{ $product->single_price }} {{ __('KWD') }}
@endif
@endforeach {{-- Optionally, loop through more products if needed --}} @foreach($moreProducts as $key => $product) @endforeach
@else

No Product Found

@endif
{{-- @if($products->count()>10) --}}
{{$products->appends(Request::except('page'))->links()}}
{{-- @endif --}}

{{__('Keep Browsing')}}

@endsection @push('asset-bottom') @endpush