@extends('admin.layout.master') @section('title', __('admin.products')) @section('styles') @endsection @section('content')
{{ __('admin.products') }}
{{ __('admin.add_product') }}
@forelse ($products as $product) @empty @endforelse
{{ __('admin.image') }} {{ __('admin.name') }} {{ __('admin.category') }} {{ __('admin.price_per_unit') }} {{ __('admin.min_calculated_price') }} {{ __('admin.sizes') }} {{ __('admin.action') }}
@if($product->getMedia('images')->count()) @foreach($product->getMedia('images')->take(2) as $image) Product Image @endforeach @else Default Image @endif {{ $product->getTranslation('name', app()->getLocale()) }} @if($product->getTranslation('description', app()->getLocale()))
{{ Str::limit($product->getTranslation('description', app()->getLocale()), 50) }} @endif
@if($product->category) {{ $product->category->getTranslation('name', app()->getLocale()) }} @else — @endif
@if($product->price_after_discount && $product->price_after_discount < $product->price_per_unit) {{ number_format($product->price_per_unit, 2) }} {{ number_format($product->price_after_discount, 2) }} @else {{ number_format($product->price_per_unit, 2) }} @endif
@php // حساب أقل سعر محسوب بناءً على الأحجام المتاحة $minPrice = null; $minPriceAfterDiscount = null; if($product->sizes->count()) { $prices = []; $discountedPrices = []; foreach($product->sizes as $size) { $basePrice = 0; if($size->size_type === 'meter' && $size->length && $size->width) { $area = $size->length * $size->width; $basePrice = $product->price_per_unit * $area; } elseif($size->size_type === 'person') { $persons = $size->number_of_person ?? 1; $basePrice = $product->price_per_unit * $persons; } if($basePrice > 0) { $prices[] = $basePrice; if($product->price_after_discount && $product->price_after_discount < $product->price_per_unit) { if($size->size_type === 'meter' && $size->length && $size->width) { $area = $size->length * $size->width; $discountedPrices[] = $product->price_after_discount * $area; } elseif($size->size_type === 'person') { $persons = $size->number_of_person ?? 1; $discountedPrices[] = $product->price_after_discount * $persons; } } } } $minPrice = $prices ? min($prices) : null; $minPriceAfterDiscount = $discountedPrices ? min($discountedPrices) : null; } @endphp @if($minPrice)
@if($minPriceAfterDiscount && $minPriceAfterDiscount < $minPrice) {{ number_format($minPrice, 2) }} {{ number_format($minPriceAfterDiscount, 2) }} @else {{ number_format($minPrice, 2) }} @endif {{-- من --}}
@else — @endif
@forelse($product->sizes as $size) @if($size->size_type === 'meter') {{ $size->length }}×{{ $size->width }}م @elseif($size->size_type === 'person') {{ $size->number_of_person }} أشخاص @endif @empty {{ __('admin.no_sizes') }} @endforelse
{{-- --}} {{-- --}} {{-- --}}
@csrf @method('DELETE')
{{ __('admin.no_products_found') }}

{{ __('admin.no_products_description') }}

{{ __('admin.add_first_product') }}
@if($products->hasPages())
{{ $products->appends(request()->query())->links() }}
@endif
@endsection @section('scripts') @endsection