@extends('backend.layouts.app') @section('content')

All Customers

{{ translate('Customers') }}
@php $incompleteCount = \App\Models\User::where('user_type','customer') ->where(function($q){ $q->whereNull('name')->orWhere('name',''); }) ->count(); @endphp @if($incompleteCount > 0) ⚠️ {{ $incompleteCount }} Incomplete @endif @if(auth()->user()->user_type == 'staff') @if ($hasIncompleteLead || !$hasUnassignedLead) My Lead @else My Lead @endif @endif
@can('delete_customer') @endcan
{{-- Filters Row --}}
{{-- Name/Email/Phone Search --}}
{{-- Followup Status Filter --}} {{-- Incomplete Filter --}} {{-- Referred Filter --}} {{-- Reward Points Filter --}} {{-- Wallet Sort --}} {{-- Date Range --}} {{-- Clear Filters --}} @if(request()->anyFilled(['search','followup_status','profile_status','referred','reward_points','wallet_sort','date_from','date_to'])) ✕ Clear @endif
@if(empty($business_partner_id)) @endif @foreach($users as $user) @php // Use batch-loaded data — no per-row DB queries $isSellerEmail = !empty($user->email) && isset($sellerEmails[$user->email]); $balance = getWalletBallance(@$user->id); $displayName = $user->name ?? null; $isIncomplete = empty($displayName); $isOtpPending = $isIncomplete && empty($user->email_verified_at); $isNamePending = $isIncomplete && !empty($user->email_verified_at); $initial = $isIncomplete ? '?' : strtoupper(substr($displayName, 0, 1)); // Referred by — from batch loaded data $referralRow = $referralMap[$user->id] ?? null; $referredBy = $referralRow ? ($referrerMap[$referralRow->user_id] ?? null) : null; @endphp @if($user != null) {{-- Customer (ID + Name + Email merged) --}} @if(empty($business_partner_id)) @endif @endif @endforeach
{{ translate('Customer') }} {{ translate('Contact') }} {{ translate('Followup') }} {{ translate('Package') }} {{ translate('Wallet') }} {{ translate('Joined') }}{{ translate('Actions') }}
{{ $initial }}
{{-- ID --}}
#{{ $user->id }}
{{-- Name row --}} @if($isOtpPending || $isNamePending) {{-- Inline edit form --}}
@if($isOtpPending) OTP Pending @else No Name ⚠️ @endif
@else
@if($user->banned == 1) @endif {{ $displayName }} @if($isSellerEmail) 🏪 @endif
@endif {{-- Email --}} @if(!$isIncomplete)
{{ $user->email }}
@endif {{-- Reward Points --}} @if(!empty($user->reward_points))
⭐ RP: {{ $user->reward_points }}
@endif {{-- Referred By --}} @if($referredBy)
👤 Ref: {{ $referredBy->name ?? '#'.$referredBy->id }}
@endif
@if($user->latestDetail) @php $status = $user->latestDetail->follow_up_status; @endphp @if($status == 'followup') Followup @elseif($status == 'not_interest') Not Interested @elseif($status == 'win') Win @elseif($status == 'not_lefting' || $status == 'not_lifting') Not Lifting @elseif($status == 'not_working') Not Working @else Not Connected @endif @else Not Connected @endif {{ $user->customer_package?->getTranslation('name') ?? 'N/A' }} {{ single_price($balance) }}
{{ $user->created_at->format('d M y') }}
{{ $user->created_at->format('h:i A') }}
{{-- Response popup --}} @can('pay_to_customer') @endcan @can('login_as_customer') @endcan @can('ban_customer') @if($user->banned != 1) @else @endif @endcan @can('delete_customer') @endcan
{{ $users->appends(request()->input())->links() }}
@endsection @section('modal') @include('modals.delete_modal') @endsection @section('script') @endsection