@extends('layouts.admin', [ 'title' => 'Customers', 'pageTitle' => 'Customers', 'active' => 'customers', ]) @php $statusVariants = [ 'active' => 'success', 'vip' => 'primary', 'new' => 'purple', 'inactive' => 'muted', ]; $sortOptions = [ 'newest' => 'Newest', 'name' => 'Name', 'spent_desc' => 'Highest Spent', 'last_visit_desc' => 'Last Visit', ]; $hasActiveFilters = collect($filters ?? []) ->filter(fn ($value, $key) => filled($value) && ! ($key === 'sort' && $value === 'newest')) ->isNotEmpty(); $summaryCards = [ ['label' => 'Total Customers', 'value' => number_format($summary['total']), 'note' => 'CRM profiles in this business', 'icon' => 'users', 'class' => 'bg-blue-50 text-booklio-primary'], ['label' => 'Returning Rate', 'value' => $summary['returning_rate'] . '%', 'note' => 'Customers with 2+ bookings', 'icon' => 'check', 'class' => 'bg-emerald-50 text-emerald-600'], ['label' => 'Outstanding Due', 'value' => '$' . number_format($summary['outstanding_due'], 2), 'note' => $summary['unpaid_invoices'] . ' unpaid invoices', 'icon' => 'file-text', 'class' => 'bg-amber-50 text-amber-600'], ['label' => 'VIP Customers', 'value' => number_format($summary['vip']), 'note' => 'High-value profiles', 'icon' => 'user', 'class' => 'bg-violet-50 text-violet-600'], ]; @endphp @section('content')

Manage customer profiles, appointment history, invoices, and notes.

Add Customer
@if (session('status'))
{{ session('status') }}
@endif
@foreach ($summaryCards as $item)

{{ $item['label'] }}

{{ $item['value'] }}

{{ $item['note'] }}

@endforeach
Filter @if ($hasActiveFilters) Reset @endif
@if ($customers->isNotEmpty())
@foreach ($customers as $customer) @php $due = (float) ($customer->due_total ?? 0); @endphp
{{ $customer->initials }}

{{ $customer->name }}

{{ $customer->phone ?: $customer->email ?: 'No contact yet' }}

{{ $customer->status_label }}

Appointments

{{ $customer->appointments_count }}

Spent

${{ number_format((float) $customer->total_spent, 2) }}

Due

${{ number_format($due, 2) }}

Last Visit

{{ $customer->last_visit_at?->format('M d, Y') ?? 'No visits' }}

View Edit
@endforeach
@else

No customers found

{{ $hasActiveFilters ? 'No customers match the current filters. Reset filters or add a new customer.' : 'Create your first customer profile to track bookings, invoices, and notes.' }}

Add Customer
@endif
@push('modals') @include('admin.customers.partials.add-modal') @foreach ($customers as $customer) @include('admin.customers.partials.edit-modal', ['customer' => $customer, 'modalId' => 'edit-customer-modal-' . $customer->id]) @endforeach @endpush @endsection