@extends('backEnd.layouts.master') @section('title', 'My Customers') @push('styles') @endpush @section('content') @php $formatCourier = function (array $stat): string { $d = (int) ($stat['d'] ?? 0); $r = (int) ($stat['r'] ?? 0); return ($d === 0 && $r === 0) ? '-' : ($d . '-' . $r); }; $courierOrderUrl = function (string $phone, string $courier) { return route('admin.orders.shipped', [ 'search' => $phone, 'courier_filter' => $courier, ]); }; @endphp

My Customers

All ({{ number_format($totalAll) }}) @if(($filteredCount ?? $totalAll) !== $totalAll) Showing {{ number_format($filteredCount) }} filtered @endif
@can('customers.block') Blocked Customers @endcan Templates
@if(request()->hasAny(['district','upazila','search','q','whatsapp','orders_filter','tier_filter'])) Reset @endif
Mark করা হলে আছে/নেই লুকায় · Filter + Export = search result
@forelse($customers as $customer) @php $phone = $customer->phone; $pStat = $phoneStats[$phone] ?? ['delivered'=>0,'returned'=>0,'total'=>0,'score'=>0]; $cStat = $courierStats[$phone] ?? ['steadfast'=>['d'=>0,'r'=>0],'pathao'=>['d'=>0,'r'=>0],'redx'=>['d'=>0,'r'=>0]]; $hint = $orderHints[$phone] ?? []; $lastOrder = $lastOrderDates[$phone] ?? null; $districtName = $customer->district ?: ($hint['district'] ?? ''); $upazilaName = $customer->upazila ?: ($hint['upazila'] ?? ''); $addressLine = $customer->address ?: ($hint['address'] ?? ''); $locMain = trim( ($districtName ?: '') . ($districtName && $upazilaName ? ' => ' : '') . ($upazilaName ?: '') ); $score = (int) ($pStat['score'] ?? 0); $delivered = (int) ($pStat['delivered'] ?? 0); $returned = (int) ($pStat['returned'] ?? 0); $phoneIntl = $phone ? \App\Services\WhatsAppService::toInternational($phone) : null; $waLinkDefault = $phone ? \App\Services\WhatsAppService::buildCustomerLink($customer, 'offer_promo') : null; $courierParts = []; if ($steadfastOn) { $label = 'S:' . $formatCourier($cStat['steadfast']); $courierParts[] = '' . $label . ''; } if ($pathaoOn) { $label = 'P:' . $formatCourier($cStat['pathao']); $courierParts[] = '' . $label . ''; } if ($redxOn) { $label = 'R:' . $formatCourier($cStat['redx']); $courierParts[] = '' . $label . ''; } if (empty($courierParts)) { $courierParts[] = 'No courier API enabled'; } $isBlocked = ! $customer->status || isset($blockedMap[$phone]); $totalOrders = (int) ($pStat['total'] ?? $customer->orders_count ?? 0); $customerTier = \App\Services\CustomerInsightsSettingsService::resolveTier( (float) ($pStat['delivered_spend'] ?? 0), $totalOrders, $customer, $insightsSettings ?? null ); @endphp @empty @endforelse
ID Customer Name Phone Number Last Order Address Customer Rank Total Order Status
{{ $customer->id }}
{{ $customer->name }} @if($isBlocked) Blocked @endif
@if($phoneIntl) {{ $phoneIntl }} @if($customer->has_whatsapp === true) @elseif($customer->has_whatsapp === false) @else @endif @if($waLinkDefault) @endif @elseif($phone) {{ $phone }} @else @endif
@if($waLinkDefault && $customer->has_whatsapp === null)
·
@endif
@if(!empty($lastOrder['last_order_at'])) @php $lastAt = \Carbon\Carbon::parse($lastOrder['last_order_at']); $daysAgo = $lastAt->copy()->startOfDay()->diffInDays(now()->startOfDay()); $agoLabel = $daysAgo === 0 ? 'আজ' : ($daysAgo . ' din age'); @endphp
{{ $agoLabel }} @if(!empty($lastOrder['order_id'])) {{ $lastAt->format('d M Y') }} @else {{ $lastAt->format('d M Y') }} @endif
@else @endif
@if($locMain)
{{ $locMain }}
@endif @if($addressLine)
Address: {{ $addressLine }}
@elseif(!$locMain)
@endif
@include('backEnd.customer.partials.tier-badge', ['tier' => $customerTier, 'sm' => true]) @if($totalOrders > 0 && $phone) {{ $totalOrders }} @else 0 @endif {!! implode(', ', $courierParts) !!}
No customers found. @if(!($search ?? '') && !($district ?? '') && !($whatsapp ?? ''))
@endif
@if($customers->hasPages())
{{ $customers->links() }}
@endif
@endsection @push('scripts') @php $exportFilterQuery = request()->only('district', 'upazila', 'search', 'q', 'whatsapp', 'orders_filter', 'tier_filter'); @endphp @endpush