@extends('layouts.admin') @section('title', __('admin_products.title')) @push('styles') .filters { display: grid; grid-template-columns: minmax(220px, 1fr) 220px auto; gap: 12px; align-items: end; margin-bottom: 20px; } .field label { display: block; margin-bottom: 7px; color: #475467; font-size: 14px; font-weight: 700; } .field input, .field select { width: 100%; padding: 11px 12px; border: 1px solid #d0d9e4; border-radius: 8px; background: #ffffff; font-size: 14px; } .checkbox-field { display: flex; align-items: center; gap: 8px; margin: 15px 0 20px; } .checkbox-field input { width: 18px; height: 18px; } .table-wrapper { overflow-x: auto; } .products-table { width: 100%; min-width: 1050px; border-collapse: collapse; } .products-table th { padding: 13px 10px; background: #0756a3; color: #ffffff; text-align: start; white-space: nowrap; } .products-table td { padding: 13px 10px; border-bottom: 1px solid #e4eaf1; vertical-align: middle; } .product-image, .no-image { width: 62px; height: 62px; border-radius: 9px; } .product-image { display: block; object-fit: cover; border: 1px solid #dce5ef; } .no-image { display: flex; align-items: center; justify-content: center; padding: 5px; background: #edf2f7; color: #667085; text-align: center; font-size: 11px; } .product-name { font-weight: 700; color: #172033; } .product-code { color: #667085; font-family: monospace; font-size: 13px; } .status-badge, .active-badge { display: inline-flex; padding: 6px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; } .status-available { background: #dff6e7; color: #176b35; } .status-on-request { background: #fff0d6; color: #955a00; } .status-unavailable { background: #fde2e2; color: #a61b1b; } .active-yes { background: #eaf3fc; color: #0756a3; } .active-no { background: #edf0f3; color: #475467; } .price-line { white-space: nowrap; line-height: 1.8; } .actions { display: flex; gap: 7px; flex-wrap: wrap; } .small-button { padding: 7px 10px; border: 0; border-radius: 7px; color: #ffffff; font-size: 12px; font-weight: 700; text-decoration: none; cursor: pointer; } .edit-button { background: #0756a3; } .delete-button { background: #b42318; } .restore-button { background: #17803d; } .empty-state { padding: 45px 20px; color: #667085; text-align: center; } .pagination-wrapper { margin-top: 22px; } @media (max-width: 800px) { .filters { grid-template-columns: 1fr; } } @endpush @section('content')
@forelse($products as $product) @php $translation = $product ->translation(app()->getLocale()) ?? $product->translation('ar') ?? $product->translations->first(); $primaryImage = $product->media ->firstWhere('is_primary', true) ?? $product->media->first(); $jodPrice = $product->basePrices ->firstWhere('currency', 'JOD'); $usdPrice = $product->basePrices ->firstWhere('currency', 'USD'); $statusClass = match ( $product->availability_status ) { 'available' => 'status-available', 'on_request' => 'status-on-request', default => 'status-unavailable', }; $statusText = match ( $product->availability_status ) { 'available' => __('admin_products.available'), 'on_request' => __('admin_products.on_request'), default => __('admin_products.unavailable'), }; @endphp @empty @endforelse
{{ __('admin_products.image') }} {{ __('admin_products.code') }} {{ __('admin_products.name') }} {{ __('admin_products.brand') }} {{ __('admin_products.stock') }} {{ __('admin_products.availability') }} {{ __('admin_products.prices') }} {{ __('admin_products.active') }} {{ __('admin_products.actions') }}
@if( $primaryImage && $primaryImage->file_path ) {{ $translation?->name ?? '' }} @else
{{ __('admin_products.no_image') }}
@endif
{{ $product->internal_code }} {{ $translation?->name ?? '—' }} {{ $product->part_brand ?? '—' }} {{ number_format($product->stock_quantity) }} {{ $statusText }}
{{ $jodPrice ? number_format((float) $jodPrice->amount, 3) : '—' }} {{ __('admin_products.jod') }}
{{ $usdPrice ? number_format((float) $usdPrice->amount, 3) : '—' }} {{ __('admin_products.usd') }}
{{ $product->is_active ? __('admin_products.active') : __('admin_products.inactive') }}
@if($product->trashed())
@csrf
@else {{ __('admin_products.edit') }}
@csrf @method('DELETE')
@endif
{{ __('admin_products.no_products') }}
@if($products->hasPages())
{{ $products->links() }}
@endif
@endsection