with('transactions')->get(); return view('admin.management.index', [ 'counts' => [ 'applications' => Application::query()->count(), 'assigned' => Application::query()->where('status', 'assigned')->count(), 'staffAssignments' => StaffAssignment::query()->where('status', 'active')->count(), 'representatives' => PoliceEscort::query()->count() + KkmRepresentative::query()->count() + JkmRepresentative::query()->count(), 'missingDocuments' => Application::query() ->whereDoesntHave('documents', fn ($query) => $query->where('document_type', 'ic_document')) ->orWhereDoesntHave('documents', fn ($query) => $query->where('document_type', 'bank_statement')) ->count(), 'incompleteBank' => Application::query() ->where(fn ($query) => $query->whereNull('bank_name')->orWhereNull('bank_account_number')) ->count(), 'wheelchairAllocated' => $allocations->sum('allocated_quantity'), 'wheelchairOutstanding' => $allocations->sum(fn (WheelchairAllocation $allocation): int => $wheelchairService->outstandingQuantity($allocation)), ], ]); } }