{{-- resources/views/bookings/show.blade.php --}} {{-- Header --}}

Booking #{{ $booking->id }} @if($booking->reference) • {{ $booking->reference }} @endif

{{ $booking->start_at?->timezone(config('app.timezone'))?->format('D, d M Y H:i') ?? '—' }} → {{ $booking->end_at?->timezone(config('app.timezone'))?->format('D, d M Y H:i') ?? '—' }} @if($booking->status) • Status: {{ Str::headline($booking->status) }}@endif

@if($booking->status) {{ Str::headline($booking->status) }} @endif @if(route('bookings.edit', $booking) ?? false) Edit @endif
{{-- Body --}}
{{-- Left column: booking summary --}}
{{-- Booking summary card (example fields – adjust to your schema) --}}

Booking Summary

Vehicle
{{ $booking->vehicle?->display_name ?? $booking->vehicle?->registration ?? '—' }}
Pickup
{{ $booking->start_at?->format('D, d M Y H:i') ?? '—' }} @if($booking->pickup_location) • {{ $booking->pickup_location }} @endif
Dropoff
{{ $booking->end_at?->format('D, d M Y H:i') ?? '—' }} @if($booking->dropoff_location) • {{ $booking->dropoff_location }} @endif
Total
@php $currency = $booking->currency ?? 'NZD'; $total = isset($booking->total_cents) ? number_format($booking->total_cents / 100, 2) : null; @endphp {{ $total ? ($currency . ' ' . $total) : '—' }}
{{-- Any other booking-related panels can go here --}}
{{-- Right column: Customer details --}} @php $customer = $booking->customer ?? null; // Prefer customer model fields; fall back to booking snapshot fields if you store them there. $email = $customer?->email ?? $booking->customer_email ?? null; $phone = $customer?->phone ?? $booking->customer_phone ?? null; // Postal address (Customer model typical fields) $addrL1 = $customer?->address_line1 ?? $booking->address_line1 ?? null; $addrL2 = $customer?->address_line2 ?? $booking->address_line2 ?? null; $addrCity= $customer?->address_city ?? $booking->address_city ?? null; $addrReg = $customer?->address_region?? $booking->address_region?? null; $addrPC = $customer?->address_postcode ?? $booking->address_postcode ?? null; $addrCtry= $customer?->address_country ?? $booking->address_country ?? null; $addressParts = array_filter([$addrL1, $addrL2, $addrCity, $addrReg, $addrPC, $addrCtry]); $address = $addressParts ? implode(', ', $addressParts) : null; // Driver’s licence – try Customer first, then Booking fallbacks $dlNumber = $customer->drivers_license_number ?? $booking->drivers_license_number ?? null; $dlCountry = $customer->drivers_license_country ?? $booking->drivers_license_country ?? null; $dlExpiry = $customer->drivers_license_expiry ?? $booking->drivers_license_expiry ?? null; $dlClass = $customer->drivers_license_class ?? $booking->drivers_license_class ?? null; $dob = $customer->date_of_birth ?? $booking->date_of_birth ?? null; // Names $customerName = $customer?->name ?? trim(($booking->first_name ?? '').' '.($booking->last_name ?? '')) ?: 'Customer'; // Convenience formatting $fmtExpiry = $dlExpiry ? \Illuminate\Support\Carbon::parse($dlExpiry)->format('d M Y') : null; $fmtDob = $dob ? \Illuminate\Support\Carbon::parse($dob)->format('d M Y') : null; @endphp

Customer

@if($customer && (route('customers.show', $customer) ?? false)) View customer @endif
Name
{{ $customerName }}
Email
@if($email) {{ $email }} @else N/A @endif
Phone
@if($phone) {{ $phone }} @else N/A @endif
Address
@if($address) {{ $address }} @else N/A @endif
Driver’s licence #
{{ $dlNumber ?? '—' }} @if($dlClass) (Class {{ $dlClass }}) @endif
Issuing country
{{ $dlCountry ?? '—' }}
Licence expiry
{{ $fmtExpiry ?? '—' }}
Date of birth
{{ $fmtDob ?? '—' }}
{{-- Actions --}}
@if($email) Email customer @endif @if($phone) Call customer @endif
{{-- Debug helper (remove if not needed) --}} @if(app()->isLocal())
{{-- DEBUG: Ensure the view gets a Booking with ->customer relation eager loaded --}} Customer ID: {{ $booking->customer_id ?? 'NULL' }}
@endif