@extends('store.layout.main') @section('title', 'Products') @section('page-header') @php $productListHeaderBtns = [[ 'href' => route('store.product.add'), 'text' => 'Add Product', 'class' => 'btn btn-primary d-inline-flex align-items-center gap-1', 'icon' => '', ]]; @endphp @endsection @section('main-container') @php $colCount = 5; $activeType = request('type', ''); $activeStock = request('stock', ''); $activeCategory = request('category', ''); $activeTax = request('tax', ''); $activeStatus = request('status', ''); $hasAnyProductFilter = filled(request('type')) || filled(request('stock')) || filled(request('category')) || filled(request('tax')) || filled(request('status')); $categoryOpts = []; foreach ($productFilterCategories ?? [] as $cat) { $categoryOpts[(string) $cat->id] = [ 'label' => $cat->name, 'bg' => '#e0f2fe', 'color' => '#0369a1', 'dot' => '#0ea5e9', ]; } $productFilterGroups = [ 'type' => [ 'label' => 'Type', 'active' => $activeType, 'default' => ['label' => 'All types', 'bg' => '#f1f5f9', 'color' => '#64748b', 'dot' => '#94a3b8'], 'options' => [ 'simple' => ['label' => 'Simple', 'bg' => '#e6f7f5', 'color' => '#0d5c56', 'dot' => '#0ca678'], 'variant' => ['label' => 'Variants', 'bg' => '#f3e8ff', 'color' => '#7c3aed', 'dot' => '#7c3aed'], ], ], 'stock' => [ 'label' => 'Stock', 'active' => $activeStock, 'default' => ['label' => 'All stock', 'bg' => '#f1f5f9', 'color' => '#64748b', 'dot' => '#94a3b8'], 'options' => [ 'in' => ['label' => 'In stock / ∞', 'bg' => '#dcfce7', 'color' => '#15803d', 'dot' => '#16a34a'], 'out' => ['label' => 'Out of stock', 'bg' => '#fee2e2', 'color' => '#b91c1c', 'dot' => '#dc2626'], 'low' => ['label' => 'Low (1–10)', 'bg' => '#fef3c7', 'color' => '#b45309', 'dot' => '#d97706'], 'unlimited' => ['label' => 'Not tracked (∞)', 'bg' => '#f1f5f9', 'color' => '#475569', 'dot' => '#64748b'], ], ], 'category' => [ 'label' => 'Category', 'active' => $activeCategory, 'default' => ['label' => 'All categories', 'bg' => '#f1f5f9', 'color' => '#64748b', 'dot' => '#94a3b8'], 'options' => $categoryOpts, ], 'tax' => [ 'label' => 'Tax', 'active' => $activeTax, 'default' => ['label' => 'All tax', 'bg' => '#f1f5f9', 'color' => '#64748b', 'dot' => '#94a3b8'], 'options' => [ 'yes' => ['label' => 'Taxable', 'bg' => '#ccfbf1', 'color' => '#0f766e', 'dot' => '#14b8a6'], 'no' => ['label' => 'No tax', 'bg' => '#f8fafc', 'color' => '#64748b', 'dot' => '#94a3b8'], ], ], 'status' => [ 'label' => 'Status', 'active' => $activeStatus, 'default' => ['label' => 'All status', 'bg' => '#f1f5f9', 'color' => '#64748b', 'dot' => '#94a3b8'], 'options' => [ 'published' => ['label' => 'Published', 'bg' => '#dcfce7', 'color' => '#15803d', 'dot' => '#16a34a'], 'draft' => ['label' => 'Draft', 'bg' => '#fef3c7', 'color' => '#b45309', 'dot' => '#d97706'], ], ], ]; $productListFpUrl = function (string $key, string $val): string { $params = []; foreach (['type', 'stock', 'category', 'tax', 'status'] as $pk) { $v = request($pk, ''); if ($v !== '' && $v !== null) { $params[$pk] = $v; } } if ($val === '') { unset($params[$key]); } else { $params[$key] = $val; } return route('store.product.list', $params); }; @endphp
{{-- Row 1: search + count --}}
Products {{ number_format($products->total()) }}
@if(isset($publishedCount) || isset($draftCount)) @endif
{{-- Row 2: filter pills (full width below search, left-aligned) --}}
@foreach($productFilterGroups as $paramKey => $cfg) @php $activeVal = $cfg['active']; $activeCfg = $activeVal !== '' && $activeVal !== null && isset($cfg['options'][$activeVal]) ? $cfg['options'][$activeVal] : $cfg['default']; @endphp
{{ $activeCfg['label'] }}
@endforeach @if($hasAnyProductFilter) Clear filters @endif
@forelse($products as $product) @empty @endforelse
# Product Price Stock Actions
{{ $products->firstItem() + $loop->index }}
@if($product->thumbnail) @else @endif
{{ $product->name }}
{{ $product->sku }}
{{ $product->formatted_price }}
@if($product->category || $product->is_variant)
@if($product->category) {{ $product->category->name }} @endif @if($product->is_variant) Variants @endif
@endif
{{ $product->formatted_total_stock }} @if($product->expiry_date_value)
Expires {{ format_date($product->expiry_date_value) }}
@endif
@if($canDeleteProduct)
@csrf @method('DELETE')
@endif
No products yet. Use Add Product to create your first item.
@if($products->hasPages()) @endif
@endsection @section('script') @endsection