keyed by page id; pages without components are absent */ public static function worstByPage(): array { return Component::query()->withoutGlobalScope('status_page') ->where('enabled', true) ->groupBy('status_page_id') ->selectRaw('status_page_id, max(status) as worst') ->pluck('worst', 'status_page_id') ->map(fn ($worst) => ComponentStatus::from((int) $worst)) ->all(); } /** "Operational", "Major outage", or "No components" when nothing is measured. */ public static function label(?ComponentStatus $status): string { return $status?->label() ?? 'No components'; } }