@extends('admin.layouts.app') @section('page-title', 'Customers') @section('content')

Customer List

{{ $allCustomers->count() }}
Total Customers
@php $newThisMonth = $allCustomers->filter(function($customer) { return $customer->created_at->format('Y-m') === now()->format('Y-m'); })->count(); @endphp {{ $newThisMonth }}
New This Month
@php $activeCustomers = $allCustomers->where('status', 'active')->count(); @endphp {{ $activeCustomers }}
Active Customers
@php $premiumCount = $allCustomers->where('customer_type', 'premium')->count(); @endphp {{ $premiumCount }}
Premium Customers
@if(!empty($status)) @endif
Active Inactive All @can('customer.create') Add Customer @endcan
{{-- NEW --}} {{-- NEW --}} @forelse($customers as $c) @php // Invoice total (with GST) $totalPayable = $c->invoices->sum('final_amount_with_gst'); // Total paid via installments $totalPaid = $c->invoices ->flatMap(fn($inv) => $inv->installments) ->sum('amount'); // Remaining amount $remainingAmount = max($totalPayable - $totalPaid, 0); @endphp @empty @endforelse
Customer Info Customer ID Orders Order Total Total PayableRemainingCreate Date Status Actions
{{ strtoupper(substr($c->customer_name,0,1)) }}
{{ $c->customer_name }}
@if($c->customer_type == 'premium') Premium Customer @else Regular Customer @endif
{{ $c->email }}
{{ $c->mobile_no }}
{{ $c->customer_id }} {{ $c->orders->count() }} ₹{{ number_format($c->orders->sum('ttl_amount'), 2) }} ₹{{ number_format($totalPayable, 2) }} @if($remainingAmount > 0) ₹{{ number_format($remainingAmount, 2) }} @else ₹0.00 @endif {{ $c->created_at ? $c->created_at->format('d-m-Y') : '-' }} @if($c->status === 'active') Active @else Inactive @endif
@csrf
No customers found.
Showing {{ $customers->firstItem() ?? 0 }} to {{ $customers->lastItem() ?? 0 }} of {{ $customers->total() }} entries
@for ($i = 1; $i <= $customers->lastPage(); $i++) {{ $i }} @endfor
@endsection