@extends('layouts.app') @section('title', 'Dashboard - PreOrder') @section('content')
@php $shippingPaymentOrders = $orders->filter(function($order) { $record = $order->shippingRecords->first(); return $record && $record->status === 'arrived_nigeria' && $order->shipping_cost > 0; }); $shippingPaymentTotal = $shippingPaymentOrders->sum('shipping_cost'); @endphp @if($shippingPaymentOrders->count() > 0)

Shipping Fee Required!

You have {{ $shippingPaymentOrders->count() }} shipment(s) that have arrived in Nigeria. Please pay shipping fee of ₦{{ number_format($shippingPaymentTotal, 2) }} to proceed with delivery.

@endif

Welcome back, {{ Auth::user()->name }}!

Here's what's happening with your account

Active Pairings

{{ $activePairings->count() }}

Total Orders

{{ $orders->count() }}

Pending Payments

{{ $orders->where('payment_status', 'pending')->count() }}

Notifications

{{ Auth::user()->unreadNotifications->count() }}

@php $pendingTotal = $closedPairings->filter(function($pairing) use ($orders) { $order = $orders->first(function($o) use ($pairing) { return $o->items->contains('product_id', $pairing->product_id); }); return $order && in_array($order->payment_status, ['pending', 'partial']); })->sum(function($pairing) use ($orders) { $order = $orders->first(function($o) use ($pairing) { return $o->items->contains('product_id', $pairing->product_id); }); return $order ? $order->total - $order->paid_amount : 0; }); $pendingPaymentOrdersTotal = $pendingPaymentOrders->sum(function($order) { return $order->total - $order->paid_amount; }); $totalPending = $pendingTotal + $pendingPaymentOrdersTotal; @endphp
@if($totalPending > 0)

Total Pending Payments

₦{{ number_format($totalPending, 0) }}

Pay All Now
@endif

Active Pairings

View All
@if($activePairings->isEmpty())

No active pairings

Browse Products
@else
@foreach($activePairings->take(5) as $pairing)
@if($pairing->product->images->first()) @endif

{{ $pairing->product->name }}

{{ $pairing->quantity }} × ₦{{ number_format($pairing->unit_price, 0) }}

₦{{ number_format($pairing->total_price, 0) }}

Active
@endforeach
@endif

Awaiting Payment

View All
@if($closedPairings->isEmpty() && $pendingPaymentOrders->isEmpty())

No pending payments

@else
@foreach($closedPairings->take(5) as $pairing) @php $order = \App\Models\Order::where('user_id', Auth::id()) ->whereHas('items', function($q) use ($pairing) { $q->where('product_id', $pairing->product_id); }) ->first(); @endphp @if($order && in_array($order->payment_status, ['pending', 'partial']))
@if($pairing->product->images->first()) @endif

{{ $pairing->product->name }}

{{ $pairing->quantity }} × ₦{{ number_format($pairing->unit_price, 0) }}

₦{{ number_format($order->total, 0) }}

Pay Now
@endif @endforeach @foreach($pendingPaymentOrders->take(5) as $order)

{{ $order->order_number }}

{{ $order->items->count() }} items

₦{{ number_format($order->total - $order->paid_amount, 0) }}

Pay Now
@endforeach
@endif

Recent Orders

View All
@if($orders->isEmpty())

No orders yet

@else
@foreach($orders->take(5) as $order)

{{ $order->order_number }}

{{ $order->items->count() }} items

₦{{ number_format($order->total, 0) }}

{{ ucfirst($order->payment_status) }}
@endforeach
@endif
@if($notifications->count() > 0)

Recent Notifications

View All
@foreach($notifications->take(5) as $notification)

{{ $notification->title }}

{{ $notification->message }}

{{ $notification->created_at->diffForHumans() }}

@if(!$notification->is_read)
@csrf
@endif
@endforeach
@endif
@endsection