user()->tenant_id; $pendingHouseholdsCount = Household::where('tenant_id', $tenantId) ->where('verification_status', 'pending') ->count(); $activeHouseholdsCount = Household::where('tenant_id', $tenantId) ->where('verification_status', 'approved') ->count(); $pendingStoresCount = PartnerStore::where('tenant_id', $tenantId) ->where('status', 'pending_kyc') ->count(); $totalQrBatches = QrCodeBatch::where('tenant_id', $tenantId)->count(); $recentPendingHouseholds = Household::where('tenant_id', $tenantId) ->where('verification_status', 'pending') ->with(['head', 'barangay']) ->latest() ->take(5) ->get() ->map(function ($h) { return [ 'id' => $h->uuid, 'full_name' => $h->head ? $h->head->full_name : '—', 'address_line' => $h->address_line, 'has_proof' => (bool)$h->proof_of_residency_uploaded, ]; }); return $this->ok([ 'metrics' => [ 'pending_households' => $pendingHouseholdsCount, 'active_households' => $activeHouseholdsCount, 'pending_stores' => $pendingStoresCount, 'total_qr_batches' => $totalQrBatches, ], 'recent_pending_households' => $recentPendingHouseholds, ]); } }