'float', 'started_at' => 'datetime', 'resolved_at' => 'datetime', ]; public function rule(): BelongsTo { return $this->belongsTo(AlertRule::class, 'alert_rule_id'); } public function server(): BelongsTo { return $this->belongsTo(Server::class); } public function isFiring(): bool { return $this->state === 'firing'; } /** * Firing-incident count for the sidebar badge. Cached (the sidebar renders on every page), but * the cache is busted the instant an incident fires or resolves (forgetFiringCount), so the badge * matches the content on the next render instead of lagging up to the TTL. */ public static function firingCount(): int { return (int) Cache::remember(self::FIRING_COUNT_CACHE, 60, fn () => static::where('state', 'firing')->count()); } public static function forgetFiringCount(): void { Cache::forget(self::FIRING_COUNT_CACHE); } }