{{-- resources/views/portal/home.blade.php --}}

Customer Portal

@php // Safe defaults $bookings = collect($bookings ?? []); $customer = $customer ?? null; // Display helpers $tz = $customer->portal_timezone ?? config('app.timezone'); $money = function (?int $cents, ?string $cur = 'NZD') { $cents = (int) ($cents ?? 0); return ($cur ?: 'NZD') . ' ' . number_format($cents / 100, 2); }; $paidSum = function ($b) { return (int) ($b->payments?->whereIn('status', ['succeeded', 'paid', 'captured', 'completed'])->sum('amount') ?? 0); }; $carLabel = function ($b) { // Try a few common fields on a related vehicle, then fall back to a string column $v = $b->vehicle ?? null; // relation or string return $b->car_label ?? ($v->name ?? $v->label ?? $v->title ?? null) ?? (is_string($v) ? $v : null) ?? '—'; }; // Next upcoming booking $next = $bookings ->filter(fn ($b) => $b->start_at && $b->start_at->isFuture()) ->sortBy('start_at') ->first(); @endphp
{{-- Welcome + Logout --}}

Welcome, {{ $customer?->first_name ?: ($customer?->full_name ?? $customer?->email ?? 'Guest') }}

@if($customer?->portal_timezone)

Times shown in {{ $customer->portal_timezone }}

@endif
@csrf
{{-- Alerts --}} @if(session('claim_ok'))
{{ session('claim_ok') }}
@endif @if(session('claim_error'))
{{ session('claim_error') }}
@endif {{-- Next / Upcoming booking --}} @if($next) @php $paid = $paidSum($next); $total = (int) ($next->total_amount ?? 0); $balance = max(0, $total - $paid); @endphp

Your next booking

Ref {{ $next->reference }} • {{ $carLabel($next) }}

Start: {{ optional($next->start_at)?->timezone($tz)->format('D, d M Y · h:ia') ?? '—' }}   —   End: {{ optional($next->end_at)?->timezone($tz)->format('D, d M Y · h:ia') ?? '—' }}

Total
{{ $money($total, $next->currency ?? 'NZD') }}
Paid
{{ $money($paid, $next->currency ?? 'NZD') }}
Balance
{{ $money($balance, $next->currency ?? 'NZD') }}
@endif {{-- All bookings --}}

My Bookings

@if($bookings->isEmpty())

No bookings found for your account.

@else
@foreach($bookings as $b) @php $paid = $paidSum($b); $total = (int) ($b->total_amount ?? 0); $balance = max(0, $total - $paid); @endphp @endforeach
Reference Car Start End Total Paid Balance Actions
{{ $b->reference }} {{ $carLabel($b) }} {{ optional($b->start_at)?->timezone($tz)->format('D, d M Y · h:ia') ?? '—' }} {{ optional($b->end_at)?->timezone($tz)->format('D, d M Y · h:ia') ?? '—' }} {{ $money($total, $b->currency ?? 'NZD') }} {{ $money($paid, $b->currency ?? 'NZD') }} {{ $money($balance, $b->currency ?? 'NZD') }} View / Pay
@endif
{{-- Claim a booking --}}

Claim a booking

@csrf

Use this if an older booking isn’t attached to your account.