@php use Illuminate\Support\Facades\Auth; use Illuminate\Support\Str; $customer = Auth::guard('customer')->user(); $customerId = $customer->id; // Site Name & Logo $siteName = \App\Models\GeneralSetting::first(); $siteInitial = strtoupper(substr($siteName->name ?? 'G', 0, 1)); $siteDisplayName = Str::limit($siteName->name ?? 'GadgetShop', 8); $generalsetting = $siteName; $darkLogo = $siteName->dark_logo ?? null; // Pending Orders Count for Badge $pendingOrdersCount = \App\Models\Order::where('customer_id', $customerId) ->whereNotIn('order_status', ['6', '11']) ->count(); // Profile Image - Use direct image path $profileImage = $customer->image ? asset($customer->image) : asset('public/uploads/default/no-image.png'); // Total Order Amount $totalOrderAmount = \App\Models\Order::where('customer_id', $customerId)->sum('amount'); @endphp My Order History | {{ $siteName->name ?? 'Gadget Style' }}

আমার অর্ডার

Profile
{{-- Summary Cards --}}

মোট অর্ডার

{{ $orders->count() }}

চলমান

{{ $pendingOrdersCount }}

মোট টাকা

৳{{ number_format($totalOrderAmount, 0) }}

{{-- Orders List --}}
@forelse($orders as $value) @php // Payment Logic $payment_record = \App\Models\Payment::where('order_id', $value->id)->orderBy('id', 'desc')->first(); $gateway_status = $payment_record ? strtolower(trim($payment_record->payment_status)) : ''; $payment_method = $payment_record ? strtolower(trim($payment_record->payment_method)) : ''; $admin_status = strtolower(trim($value->payment_status ?? '')); $order_status = strtolower(trim($value->status->slug ?? $value->status->name ?? '')); $grand_total = $value->amount; $paid_amount = 0; // Payment calculation logic if ($payment_record && !in_array($gateway_status, ['failed', 'cancel', 'cancelled', 'rejected'])) { $paid_amount = $payment_record->amount; } $is_cod = in_array($payment_method, ['cod', 'cash', 'cash_on_delivery']); $is_order_completed = in_array($order_status, ['completed', 'delivered']) || in_array($admin_status, ['completed', 'delivered']); if ($is_cod && !$is_order_completed) { if ($paid_amount >= $grand_total) { $paid_amount = 0; } } if ($is_order_completed) { $paid_amount = $grand_total; } elseif (($paid_amount == 0 || !$payment_record) && in_array($admin_status, ['paid', 'success', 'approved'])) { $paid_amount = $grand_total; } $due_amount = max(0, $grand_total - $paid_amount); $is_failed = false; if ($paid_amount == 0 && in_array($gateway_status, ['failed', 'cancel', 'cancelled'])) { $is_failed = true; } $show_download = ($paid_amount >= $grand_total) || ($paid_amount > 0 && !$is_failed); $digitalDownloads = \App\Models\DigitalDownload::where('order_id', $value->id)->get(); $hasDigitalProduct = $digitalDownloads->count() > 0; // Order Status Badge $statusClass = ''; $statusText = $value->status ? $value->status->name : 'Pending'; if($value->order_status == '6') { $statusClass = 'bg-green-50 text-green-600'; $statusText = 'Completed'; } elseif($value->order_status == '11') { $statusClass = 'bg-red-50 text-red-600'; $statusText = 'Cancelled'; } elseif(in_array($value->order_status, ['3', '4', '5'])) { $statusClass = 'bg-orange-50 text-orange-600'; $statusText = 'Shipped'; } else { $statusClass = 'bg-gray-50 text-gray-600'; $statusText = 'Pending'; } // Refund Logic $canRefund = false; $hasPendingRefund = method_exists($value, 'hasPendingRefund') ? $value->hasPendingRefund() : false; if ($value->order_status != 11 && $paid_amount > 0 && !$hasPendingRefund) { $canRefund = true; } $existingRefund = \App\Models\Refund::where('order_id', $value->id) ->whereIn('status', ['pending', 'approved']) ->first(); @endphp {{-- Order Card - Simplified --}}
{{-- Header Row --}}

#{{ $value->invoice_id ?? $value->id }}

{{ $statusText }}

{{ $value->created_at->format('d M, Y - h:i A') }}

৳{{ number_format($grand_total, 2) }}

{{-- Product Images --}} @if($value->orderdetails && $value->orderdetails->count() > 0)
@foreach($value->orderdetails->take(5) as $detail) @php $productImage = null; if ($detail->product && $detail->product->image) { $productImage = $detail->product->image->image; } elseif ($detail->image) { $productImage = $detail->image->image; } @endphp {{ $detail->product_name ?? 'Product' }} @endforeach @if($value->orderdetails->count() > 5)
+{{ $value->orderdetails->count() - 5 }}
@endif
@endif {{-- Payment & Actions Row --}}
{{-- Payment Status --}}
Paid: ৳{{ number_format($paid_amount, 2) }}
Due: ৳{{ number_format($due_amount, 2) }}
@if($paid_amount >= $grand_total) Paid @elseif($is_failed) Failed @elseif($paid_amount > 0) Partial @else @if($is_cod) COD @else Unpaid @endif @endif
{{-- Action Buttons --}}
@if($value->admin_note) @endif @if($hasDigitalProduct && $show_download) @foreach($digitalDownloads as $dl) @endforeach @endif @if($canRefund) @elseif($existingRefund) @endif
@empty
কোনো অর্ডার পাওয়া যায়নি

আপনি এখনো কোনো অর্ডার করেননি।

@endforelse
{{-- Pagination --}} @if(method_exists($orders, 'hasPages') && $orders->hasPages())
{{-- Previous Page Link --}} @if ($orders->onFirstPage()) @else @endif {{-- Pagination Elements --}} @php $currentPage = $orders->currentPage(); $lastPage = $orders->lastPage(); $startPage = max(1, $currentPage - 2); $endPage = min($lastPage, $currentPage + 2); @endphp @if($startPage > 1) 1 @if($startPage > 2) ... @endif @endif @for($page = $startPage; $page <= $endPage; $page++) @if ($page == $currentPage) {{ $page }} @else {{ $page }} @endif @endfor @if($endPage < $lastPage) @if($endPage < $lastPage - 1) ... @endif {{ $lastPage }} @endif {{-- Next Page Link --}} @if ($orders->hasMorePages()) @else @endif
@endif