@forelse($customers as $customer) {{ $customer->first_name }} {{ $customer->last_name }} {{ $customer->address }} {{ $customer->phone }} {{ $customer->sales->count() }} {{ number_format($customer->payments->sum('amount')) }} AFN @php $totalSales = $customer->sales->sum(function($sale) { return $sale->items->sum('total_price'); }); $totalPaid = $customer->payments->sum('amount'); $remaining = $totalSales - $totalPaid; @endphp @if($remaining > 0) {{ number_format($remaining) }} AFN @else هیچ باقی‌مانده‌ای نیست @endif {{ number_format($totalSales) }} AFN | | @empty هیچ مشتری‌ای ثبت نشده است @endforelse