@extends('layouts.app') @section('title', __('dashboard.sidebar_customers')) @section('page_heading', __('dashboard.sidebar_customers')) @section('content') @php $currentState = $state ?? request('state', 'active'); $totalCustomers = \App\Models\User::where('type','customer')->count(); $totalWithRes = \App\Models\User::where('type','customer')->whereHas('customer_reservations')->count(); $totalWithSales = \App\Models\User::where('type','customer')->whereHas('customer_purchases')->count(); @endphp {{-- KPIs --}}
@foreach([ ['fa-solid fa-users', '#eff6ff','#2563eb', $totalCustomers, __('dashboard.total_customers')], ['fa-solid fa-calendar-check','#f0fdf4','#16a34a', $totalWithRes, __('dashboard.have_reservations')], ['fa-solid fa-cart-shopping', '#fffbeb','#d97706', $totalWithSales, __('dashboard.have_purchases')], ] as [$ic,$bg,$cl,$val,$lbl])
{{ $val }}
{{ $lbl }}
@endforeach
{{-- Table card --}}
{{-- Head --}}
{{ __('dashboard.All Customers') }} {{ number_format($customers->total()) }}
{{-- State tabs --}}
@foreach(['active' => __('dashboard.status_active'), 'trashed' => __('dashboard.status_deleted'), 'all' => __('dashboard.all')] as $val => $lbl) {{ $lbl }} @endforeach
{{-- Search --}}
@can('create customers') {{ __('dashboard.Add New Customer') }} @endcan
@if($customers->isEmpty())
@include('layouts.partials.index-empty-state',['icon'=>'fa-solid fa-users','title'=>__('dashboard.No customers found.'),'message'=>''])
@else
@foreach(['#','العميل','الهاتف','المحافظة','تاريخ الإضافة',''] as $h) @endforeach @foreach($customers as $cust) @php $phone = filled($cust->phone) ? preg_replace('/[^\d]/','', $cust->phone) : null; $phone2 = filled($cust->other_phone) ? preg_replace('/[^\d]/','', $cust->other_phone) : null; if ($phone && strlen($phone) === 11 && $phone[0] === '0') $phone = '2'.$phone; if ($phone2 && strlen($phone2) === 11 && $phone2[0] === '0') $phone2 = '2'.$phone2; @endphp @endforeach
{{ $h }}
{{ $cust->id }}
{{ mb_substr($cust->name,0,1) }}
{{ $cust->name }}
@if($cust->trashed()) محذوف @endif
@foreach(array_filter([[$cust->phone,$phone],[$cust->other_phone,$phone2]]) as [$raw,$wa]) @if($raw)
{{ $raw }}
@endif @endforeach @if(!$cust->phone && !$cust->other_phone)@endif
{{ $cust->governorate ?: '—' }} {{ $cust->created_at->format('Y-m-d') }} @canany(['view customers','edit customers','delete customers'])
@if($cust->trashed())
@csrf
@else @can('view customers') عرض الملف @endcan @can('edit customers') تعديل @endcan @can('delete customers')
@csrf @method('DELETE')
@endcan @endif
@endcanany
{{ $customers->appends(request()->query())->links() }}
@endif
@endsection