@extends('layouts.app') @section('title', 'Customer — ' . ($customer->name ?? 'Details')) @push('styles') @endpush @section('content') @if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif @if($errors->any())
Please fix the following:
@endif {{-- Dedup banner: another rep contacted this customer recently. --}} @if(!empty($recentContactWarning))
Heads up — {{ $recentContactWarning['by'] }} already contacted this customer {{ $recentContactWarning['when']->diffForHumans() }} via {{ ucfirst($recentContactWarning['channel'] ?? '—') }}. @if(!empty($recentContactWarning['outcome']))
“{{ \Illuminate\Support\Str::limit($recentContactWarning['outcome'], 200) }}”
@endif
Avoid double-contacting unless this is a different conversation.
@endif {{-- Contact status card --}} @php $statusOptions = $contactStatusOptions ?? []; $currentStatusKey = $customer->contact_status ?: 'pending'; $currentStatus = $statusOptions[$currentStatusKey] ?? ['label' => 'Pending', 'color' => '#6c7781']; $followUpDue = $customer->next_follow_up_at && $customer->next_follow_up_at->lte(now()->addDay()); @endphp

Contact Tracking

{{ $currentStatus['label'] }}
Last contacted
@if($customer->last_contacted_at)
{{ $customer->last_contacted_at->diffForHumans() }}
@if($customer->last_contact_channel) via {{ ucfirst($customer->last_contact_channel) }} @endif @if($customer->lastContactedByStaff && optional($customer->lastContactedByStaff->user)->name) by {{ $customer->lastContactedByStaff->user->name }} @endif
@else
Never
@endif
Next follow-up
@if($customer->next_follow_up_at)
{{ $customer->next_follow_up_at->format('M j, Y') }} @if($followUpDue) Due @endif
{{ $customer->next_follow_up_at->diffForHumans() }}
@csrf
@else
None scheduled
@endif
@if($customer->last_contact_outcome)
Last outcome
“{{ $customer->last_contact_outcome }}”
@endif
@csrf
{{-- Inline "Record Contact" form (hidden by default) --}}
{{-- Contact timeline --}} @if(!empty($timeline) && count($timeline) > 0)

Contact Timeline

@endif
{{-- LEFT COLUMN --}}
{{-- Profile Edit --}}

Profile

@csrf @method('PUT')
@error('name')
{{ $message }}
@enderror
@error('email')
{{ $message }}
@enderror
@error('phone')
{{ $message }}
@enderror
@error('company')
{{ $message }}
@enderror
@error('address')
{{ $message }}
@enderror
@error('city')
{{ $message }}
@enderror
@error('state')
{{ $message }}
@enderror
@error('country')
{{ $message }}
@enderror
@error('tag')
{{ $message }}
@enderror
@error('notes')
{{ $message }}
@enderror
{{-- Send Message --}}

Send Message

@csrf
@error('channel')
{{ $message }}
@enderror
@error('subject')
{{ $message }}
@enderror
@error('body')
{{ $message }}
@enderror
{{-- Order History --}}

Order History

@if($customer->orders && $customer->orders->count())
@foreach($customer->orders as $order) @endforeach
Order # Status Total Placed
{{ $order->order_number ?? ('ORD-' . str_pad($order->id, 5, '0', STR_PAD_LEFT)) }} {{ ucfirst($order->status ?? 'pending') }} ₦{{ number_format($order->total ?? 0, 2) }} {{ $order->created_at ? $order->created_at->format('M d, Y') : '—' }}
@else
No orders yet
@endif
{{-- RIGHT COLUMN --}}
{{-- Stats --}}

Stats

Total Orders {{ number_format($customer->total_orders ?? 0) }}
Completed {{ number_format($customer->completed_orders ?? 0) }}
Cancelled {{ number_format($customer->cancelled_orders ?? 0) }}
Total Spent ₦{{ number_format($customer->total_spent ?? 0, 2) }}
First Order {{ $customer->first_order_at?->format('M d, Y') ?? '—' }}
Last Order {{ $customer->last_order_at?->format('M d, Y') ?? '—' }}
{{-- Risk Score --}} @isset($risk) @php $bandClass = $risk['band'] === 'high' ? 'danger' : ($risk['band'] === 'medium' ? 'warning' : 'success'); $bandColor = $risk['band'] === 'high' ? 'var(--danger)' : ($risk['band'] === 'medium' ? 'var(--warning)' : 'var(--success)'); @endphp

Risk Score

{{ $risk['score'] }}
Risk Band
{{ ucfirst($risk['band']) }}
out of 100
@if(!empty($risk['signals']))
    @foreach($risk['signals'] as $signal)
  • {{ $signal }}
  • @endforeach
@else

No risk signals detected.

@endif
@csrf
@endisset {{-- Status Card --}}

Status

@if($customer->is_blocked)
@csrf
@else
@csrf
@error('reason')
{{ $message }}
@enderror
@endif
{{-- Risk Score --}} @if(($customer->risk_score ?? 0) > 0) @php $risk = (int) $customer->risk_score; $riskClass = $risk >= 70 ? 'risk-high' : ($risk >= 40 ? 'risk-medium' : 'risk-low'); $riskText = $risk >= 70 ? 'High Risk' : ($risk >= 40 ? 'Medium Risk' : 'Low Risk'); @endphp

Risk

{{ $riskText }} {{ $risk }}/100
Based on order history, disputes, and reported issues.
@endif
@endsection @push('scripts') @endpush