{{ $client->full_name }}
{{-- Header --}}

{{ $client->full_name }}

@if($stats['last_visit']) Last visit {{ $stats['last_visit']->diffForHumans() }} ({{ $stats['last_visit']->format('d M Y') }}) @else No visits recorded yet @endif

Edit Back
{{-- Success Message --}} @if(session('success'))

{{ session('success') }}

@endif {{-- Stats Cards --}}

Total Visits

{{ $stats['total_visits'] }}

Total Spent

KSh {{ number_format($stats['total_spent'], 0) }}

Avg per Visit

KSh {{ number_format($stats['avg_spend'], 0) }}

Balance Due

KSh {{ number_format($stats['balance_due'], 0) }}

{{-- Two-Column: Client Info + Vehicles --}}
{{-- Client Details Card --}}

Client Details

Phone
@if($client->phone) {{ $client->phone }} @else @endif
Email
@if($client->email) {{ $client->email }} @else @endif
Status
@if($client->status === 'active') Active @else Inactive @endif
Last Visit
{{ $stats['last_visit'] ? $stats['last_visit']->format('d M Y') : '—' }}
Member Since
{{ $client->created_at->format('d M Y') }}
@if($client->notes)
Notes
{{ $client->notes }}
@endif
{{-- Vehicles Card --}}

Vehicles

{{-- Add Vehicle Form --}}
@csrf
{{-- Vehicles List --}} @if($client->vehicles->isEmpty())

No vehicles added yet

@else
@foreach($client->vehicles as $vehicle)

{{ $vehicle->plate_number }}

{{ $vehicle->type ?? 'No type specified' }}

@endforeach
@endif
{{-- Visit History --}}

Visit History

{{ $stats['total_visits'] }} visit{{ $stats['total_visits'] !== 1 ? 's' : '' }}
@if($sales->isEmpty())

No visits recorded yet

@else
@foreach($sales as $sale) @php $services = collect($sale->service_items ?? []) ->map(fn($si) => $si['service_name'] ?? $si['name'] ?? 'Service') ->unique()->implode(', '); $products = $sale->items->map(fn($i) => $i->product?->name ?? 'Product')->implode(', '); $desc = implode('; ', array_filter([$services, $products])) ?: '—'; $balance = $sale->remaining_balance; $statusColor = match($sale->status) { 'completed' => 'bg-green-100 text-green-800', 'partial' => 'bg-amber-100 text-amber-800', default => 'bg-gray-100 text-gray-600', }; @endphp @endforeach
Date & Time Services / Items Total Paid Status
{{ $sale->sale_date->format('d M Y') }}
{{ $sale->sale_date->format('H:i') }}
{{ $desc }}
{{ $sale->reference_no }}
KSh {{ number_format($sale->total, 2) }} KSh {{ number_format($sale->total_paid, 2) }} {{ ucfirst($sale->status) }} View →
{{ $stats['total_visits'] }} visits KSh {{ number_format($stats['total_spent'], 2) }} KSh {{ number_format($stats['total_paid'], 2) }}
@endif
{{-- Statement Modal --}} @push('scripts') @endpush