@extends('layouts.app') @section('title', 'Customers') @push('styles') @endpush @section('content') @if(session('success'))
{{ session('success') }}
@endif {{-- Stats Cards --}}
Total Customers {{ number_format($stats['total'] ?? 0) }}
VIP {{ number_format($stats['vip'] ?? 0) }}
Flagged {{ number_format($stats['flagged'] ?? 0) }}
Blocked {{ number_format($stats['blocked'] ?? 0) }}
{{-- Assignee quick-filter chips --}}
@php $chipStyle = 'padding:0.35rem 0.85rem;border-radius:999px;font-size:0.78rem;font-weight:600;text-decoration:none;border:1px solid var(--border);'; $chipActive = 'background:var(--accent);color:#fff;border-color:var(--accent);'; $chipIdle = 'color:var(--text-secondary,#6b7280);background:var(--bg-card);'; @endphp All ({{ $stats['total'] ?? 0 }}) @if($currentStaff) My Customers ({{ $stats['mine'] ?? 0 }}) @endif Unassigned ({{ $stats['unassigned'] ?? 0 }}) @foreach(($teamMembers ?? []) as $m) @php $mName = optional($m->user)->name ?? 'Staff #'.$m->id; @endphp {{ $mName }} @endforeach
{{-- Contact-status quick filters --}}
Contact: All Follow-up due ({{ $stats['follow_up_due'] ?? 0 }}) Never contacted ({{ $stats['never_contacted'] ?? 0 }}) @foreach(($contactStatusOptions ?? []) as $key => $opt) @if($key === 'pending') @continue @endif {{ $opt['label'] }} @endforeach
{{-- Filter Bar --}}
@if(! empty($assignee))@endif
{{-- Customers Table --}} @if(isset($customers) && $customers->count())
@foreach($customers as $customer) @php $tag = $customer->tag ?? 'new'; $tagStyles = [ 'vip' => 'background: rgba(255, 193, 7, 0.15); color: #ffc107;', 'flagged' => 'background: rgba(255, 71, 87, 0.15); color: #ff4757;', 'regular' => 'background: rgba(16, 191, 255, 0.15); color: var(--accent);', 'new' => 'background: rgba(99, 110, 114, 0.15); color: #a4b0be;', ]; $tagStyle = $tagStyles[$tag] ?? $tagStyles['new']; @endphp @endforeach
Name Email Phone Total Orders Total Spent Tag Assigned To Last Contacted Last Order Action
{{ $customer->name ?? '—' }} @if($customer->is_blocked) Blocked @endif {{ $customer->email ?? '—' }} {{ $customer->phone ?? '—' }} {{ number_format($customer->total_orders ?? 0) }} ₦{{ number_format($customer->total_spent ?? 0, 2) }} {{ ucfirst($tag) }} @php $rs = (int) ($customer->risk_score ?? 0); $rBand = $rs >= 70 ? 'high' : ($rs >= 40 ? 'medium' : 'low'); $rColor = $rBand === 'high' ? 'var(--danger)' : ($rBand === 'medium' ? 'var(--warning)' : 'var(--success)'); @endphp @if($rs > 0) {{ $rs }} @endif {{-- Assignee chip + inline reassign (owner/manager only) --}} @if($customer->assigned_to && $customer->assignedStaff) {{ optional($customer->assignedStaff->user)->name ?? 'Staff #'.$customer->assigned_to }} @else Unassigned @endif @php // Owner and staff-with-customers.manage get the inline reassign. $canReassign = (! $currentStaff) || ($currentStaff && $currentStaff->can_do('customers.manage')); @endphp @if($canReassign)
@csrf
@endif
@php $statusKey = $customer->contact_status ?: 'pending'; $statusInfo = ($contactStatusOptions ?? [])[$statusKey] ?? null; $followUpDue = $customer->next_follow_up_at && $customer->next_follow_up_at->lte(now()); @endphp @if($customer->last_contacted_at)
{{ $customer->last_contacted_at->diffForHumans() }}
@if($customer->last_contact_channel)
via {{ ucfirst($customer->last_contact_channel) }} @if($customer->lastContactedByStaff && optional($customer->lastContactedByStaff->user)->name) · {{ \Illuminate\Support\Str::words(optional($customer->lastContactedByStaff->user)->name, 1, '') }} @endif
@endif @else Never @endif @if($statusInfo && $statusKey !== 'pending')
{{ $statusInfo['label'] }}
@endif @if($followUpDue)
Follow-up due
@endif
{{ $customer->last_order_at ? $customer->last_order_at->diffForHumans() : 'Never' }} View
{{ $customers->withQueryString()->links() }}
@else

No customers yet

Customers are created automatically when orders are placed. Once you have orders, customer profiles will appear here.

@endif @endsection