*/ protected function getStats(): array { $tenant = Filament::getTenant(); if (! $tenant instanceof Tenant) { return []; } $summary = app(TenantDashboardSummaryBuilder::class)->build($tenant, auth()->user()); $stats = []; foreach ($summary->kpis as $kpi) { if (count($stats) >= 4) { break; } $color = $kpi['tone'] === 'gray' ? null : $kpi['tone']; $icon = is_string($kpi['icon'] ?? null) ? $kpi['icon'] : null; $chart = is_array($kpi['chart'] ?? null) ? $kpi['chart'] : null; $stat = Stat::make($kpi['label'], (string) $kpi['value']) ->description($kpi['description']) ->color($color) ->extraAttributes([ 'data-testid' => 'tenant-dashboard-kpi', 'data-kpi-key' => (string) ($kpi['key'] ?? ''), 'data-kpi-has-icon' => $icon !== null ? 'true' : 'false', 'data-kpi-has-chart' => $chart !== null ? 'true' : 'false', ]); if ($icon !== null) { $stat->descriptionIcon($icon); } if ($chart !== null) { $stat->chart(array_map(static fn (mixed $point): int => (int) $point, $chart)); } if (!empty($kpi['actionUrl'])) { $stat->url($kpi['actionUrl']); } $stats[] = $stat; } return $stats; } }