@extends('backend.template.layouts.template-base')
@section('title', 'Customer Details | ' . config('app.name'))
@section('styles')
@endsection
@section('content')
@php
$displayName = $customer->name ?: 'Customer #' . $customer->id;
$initial = strtoupper(substr($displayName, 0, 1));
$verified = (int) $customer->is_mobile_verified === 1 || $customer->mobile_verified_at;
$defaultAddr = $customer->defaultAddress;
$activeTab = session('active_tab', 'overview');
$firstOrderDate = $metrics['first_order_date']
? \Carbon\Carbon::parse($metrics['first_order_date'])->format('d M Y, h:i A') : '-';
$lastOrderDate = $metrics['last_order_date']
? \Carbon\Carbon::parse($metrics['last_order_date'])->format('d M Y, h:i A') : '-';
$sourceBadge = match ($customer->source ?? 'app') {
'web' => 'cm-badge-blue',
'manual' => 'cm-badge-amber',
default => 'cm-badge-indigo',
};
// JSON addresses for JS modal population
$addressesJson = $customer->addresses->map(fn ($a) => [
'id' => $a->id,
'label' => $a->label,
'name' => $a->name,
'mobile' => $a->mobile,
'address_line_1' => $a->address_line_1,
'address_line_2' => $a->address_line_2,
'city' => $a->city,
'state' => $a->state,
'pincode' => $a->pincode,
'delivery_instructions' => $a->delivery_instructions,
'is_default' => (bool) $a->is_default,
])->keyBy('id');
@endphp
{{-- ── Header ──────────────────────────────────────────────────────── --}}
Customer Details
Customers > {{ $displayName }}
Edit Customer
{{-- ── Profile + Metrics ──────────────────────────────────────────── --}}
{{-- Profile card --}}
{{ $initial }}
{{ $displayName }}
#{{ $customer->id }}
{{ ucfirst($customer->source ?? 'app') }}
{{ $customer->mobile ?: '-' }}
@if ($customer->email)
{{ $customer->email }}
@endif
Joined {{ $customer->created_at?->format('d M Y') ?: '-' }}
{{ $verified ? 'OTP Verified' : 'Unverified' }}
{{ $customer->status ? 'Active' : 'Inactive' }}
{{-- Metric cards --}}
Total Orders
{{ number_format($metrics['total_orders']) }}
Completed
{{ number_format($metrics['completed_orders']) }}
Total Revenue
₹{{ number_format($metrics['total_revenue'], 0) }}
Avg Order
₹{{ number_format($metrics['average_order_value'], 0) }}
{{-- ── Tab Card ─────────────────────────────────────────────────────── --}}
-
-
-
-
-
{{-- ── Overview Tab ────────────────────────────────────────── --}}
Mobile Number
{{ $customer->mobile ?: '-' }}
Email Address
{{ $customer->email ?: '-' }}
Registration Source
{{ ucfirst($customer->source ?? 'app') }}
Account Status
{{ $customer->status ? 'Active' : 'Inactive' }}
OTP Verified
{{ $verified ? 'Verified' : 'Unverified' }}
OTP Verified At
{{ $customer->mobile_verified_at?->format('d M Y, h:i A') ?: '-' }}
First Order Date
{{ $firstOrderDate }}
Last Order Date
{{ $lastOrderDate }}
Cancelled Orders
{{ number_format($metrics['cancelled_orders']) }}
Registered On
{{ $customer->created_at?->format('d M Y, h:i A') ?: '-' }}
Last Updated
{{ $customer->updated_at?->format('d M Y, h:i A') ?: '-' }}
Default Address
{{ collect([$defaultAddr?->city, $defaultAddr?->pincode])->filter()->implode(', ') ?: '-' }}
{{-- ── Addresses Tab ───────────────────────────────────────── --}}
Saved Addresses ({{ $customer->addresses->count() }})
@if ($customer->addresses->isEmpty())
No addresses found. Add one above.
@else
@foreach ($customer->addresses as $address)
@php
$addrLine = collect([
$address->address_line_1,
$address->address_line_2,
$address->city,
$address->state,
$address->pincode,
])->filter()->implode(', ');
@endphp
{{ $address->label }}
@if ($address->is_default)
Default
@endif
@if ($address->name)
{{ $address->name }}
@endif
@if ($address->mobile)
{{ $address->mobile }}
@endif
@if ($addrLine)
{{ $addrLine }}
@endif
@if ($address->delivery_instructions)
"{{ $address->delivery_instructions }}"
@endif
@endforeach
@endif
{{-- ── Orders Tab ──────────────────────────────────────────── --}}
| Order ID |
Order Date |
Status |
Payment Status |
Method |
Amount |
Delivery Address |
Action |
{{-- ── Activity Log Tab ────────────────────────────────────── --}}
@if ($activityLogs->isEmpty())
No activity recorded yet.
@else
@foreach ($activityLogs as $log)
-
{{ $log->description }}
{{ $log->created_at->format('d M Y, h:i A') }}
· {{ $log->created_at->diffForHumans() }}
@if ($log->admin)
By: {{ $log->admin->name }}
@else
Customer action
@endif
@if (!empty($log->properties))
@foreach ($log->properties as $key => $val)
| {{ ucfirst(str_replace('_', ' ', $key)) }} |
@if (is_array($val))
{{ $val['from'] ?? '' }} → {{ $val['to'] ?? '' }}
@else
{{ $val }}
@endif
|
@endforeach
@endif
@endforeach
@endif
{{-- ── Notify Me Tab ────────────────────────────────────────── --}}
Back-in-Stock Notifications ({{ $notifyMeRequests->count() }})
@if ($notifyMeRequests->isEmpty())
No notify-me requests found.
@else
| Product |
Pricing / Label |
Status |
Requested At |
Notified At |
@foreach ($notifyMeRequests as $nm)
@php
$nmImg = $nm->product?->image
? \App\Helpers\Helper::storage_url($nm->product->image)
: asset('backend/template/images/svg/img.svg');
$nmLabel = $nm->pricing?->label ?: ($nm->product?->name ?: '-');
@endphp
{{ $nm->product?->name ?? '-' }}
|
{{ $nmLabel }} |
{{ $nm->status === 'pending' ? 'Pending' : 'Notified' }}
|
{{ $nm->created_at?->format('d M Y, h:i A') ?? '-' }}
|
{{ $nm->notified_at?->format('d M Y, h:i A') ?? '-' }}
|
@endforeach
@endif
{{-- /tab-content --}}
{{-- /card-tab-border --}}
{{-- ── Notify Me Detail Modal ──────────────────────────────────────────── --}}
{{-- ── Address Modal ──────────────────────────────────────────────────── --}}
@endsection
@section('scripts')
@endsection