33 lines
638 B
PHP
33 lines
638 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class AlertIncident extends Model
|
|
{
|
|
protected $guarded = [];
|
|
|
|
protected $casts = [
|
|
'value' => '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';
|
|
}
|
|
}
|