@extends('components.customer_layout')
@section('customer-content')
@php
// use App\Models\CustomerApplication;
// use App\Models\Office;
// use Illuminate\Support\Facades\DB;
$selectedOffice = request('office');
$selectedStatus = request('status');
$applicationsQuery = App\Models\CustomerApplications::query();
if ($selectedOffice && $selectedOffice != '0') {
$applicationsQuery->where('office_id', $selectedOffice);
}
// if ($selectedStatus && $selectedStatus != '0') {
// $applicationsQuery->where('status', $selectedStatus);
// }
$applicationsOverTime = (clone $applicationsQuery)
->selectRaw('DATE(created_at) as date, COUNT(*) as total')
->groupBy('date')
->orderBy('date')
->get();
$applicationsByModel = (clone $applicationsQuery)
->select('model', DB::raw('count(*) as total'))
->groupBy('model')
->get();
$applicationsByService = (clone $applicationsQuery)
->select('service_id', DB::raw('count(*) as total'))
->groupBy('service_id')
->get();
$applicationsByOffice = (clone $applicationsQuery)
->select('office_id', DB::raw('count(*) as total'))
->groupBy('office_id')
->get();
$offices = \App\Models\Office::orderBy('name')->get();
$applications = App\Models\CustomerApplications::with(['model', 'office','service'])->paginate(10);
@endphp
| Office |
Services |
Created At |
Status |
@foreach($applications as $app)
@php
$status = $app->model->status ?? 'Unknown';
$statusClass = $status === 'rejected' ? 'text-danger fw-bold' : '';
$appType = class_basename($app->model_type); // e.g. "Land", "Business"
@endphp
| {{ $app->office->name ?? 'N/A' }} |
{{ $app->service->name }} |
{{ $app->created_at}} |
{{ ucfirst($status) }} |
@endforeach
{{ $applications->links('pagination::bootstrap-4') }}
Gaaffii Tajaajilaa waajjiraalee
| Maqaa Waajjira |
Waliigala |
@foreach($applicationsByOffice as $item)
@php
$officeName = optional($offices->firstWhere('id', $item->office_id))->name ?? 'Unknown';
@endphp
| {{ $officeName }} |
{{ $item->total }} |
@endforeach
@endsection