@extends('layout.admin.master') @section('meta-title', 'Products') @section('body-class', 'menu-position-side menu-side-left full-screen with-content-panel') @section('breadcrumbs') @endsection @push('asset-top') @endpush @section('content')
Products
@if($products instanceof \Illuminate\Pagination\LengthAwarePaginator) Showing {{ $products->count() }} of {{ $products->total() }} results @else Showing {{ $products->count() }} results @endif
Add
@php $sortedProducts = []; $otherProducts = []; // Sort products based on 'location' foreach($products as $product) { if (!empty($product->location) && $product->location > 0) { $sortedProducts[$product->location] = $product; } else { $otherProducts[] = $product; } } // Sort the products with 'location' by key ksort($sortedProducts); // Take the first 9 sorted products $finalProducts = array_slice($sortedProducts, 0, 9); $remainingSlots = 9 - count($finalProducts); // Fill remaining slots with products that don't have a 'location' if ($remainingSlots > 0) { $finalProducts = array_merge($finalProducts, array_slice($otherProducts, 0, $remainingSlots)); } // Merge any additional products for later use $moreProducts = array_merge(array_slice($sortedProducts, 9), array_slice($otherProducts, $remainingSlots)); @endphp {{-- Loop through final products and display in the table --}} @foreach($finalProducts as $product) @php $prices = json_decode($product->price, true); $quantity = json_decode($product->quantity, true); @endphp @endforeach {{-- Optionally, loop through more products if needed --}} @foreach($moreProducts as $product) @php $prices = json_decode($product->price, true); $quantity = json_decode($product->quantity, true); @endphp @endforeach
# Name Placed Location Category Price Quantity Status Action
@if($product->thumbnail)@endif {{$product->name_en}} {{$product->location ? $product->location : "#"}} {{(app()->currentLocale()=='en') ? $product->cat_en : $product->cat_ar}} {{$product->single_price}} {{$product->single_quantity}}
@if($product->thumbnail)@endif {{$product->name_en}} {{$product->location ? $product->location : "#"}} {{(app()->currentLocale()=='en') ? $product->cat_en : $product->cat_ar}} @if($product->single_price) {{$product->single_price}} @else @if(is_array($prices)) @foreach($prices as $key => $value) {{$key}} : {{$value}}
@endforeach @endif @endif
@if($product->single_quantity) {{$product->single_quantity}} @else @if(is_array($quantity)) @foreach($quantity as $key => $value) {{$key}} : {{$value}}
@endforeach @endif @endif
@if(!$hasFilters) {{ $products->links() }} @else

Showing {{ $products->count() }} results

@endif
@endsection