Files
2026-03-19 19:47:06 +02:00

43 lines
813 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class AlertRule extends Model
{
use HasUlids;
protected $fillable = [
'project_id',
'type',
'enabled',
'config',
];
protected function casts(): array
{
return [
'enabled' => 'boolean',
'config' => 'array',
];
}
public function project(): BelongsTo
{
return $this->belongsTo(Project::class);
}
public function getSpikeThreshold(): int
{
return $this->config['threshold'] ?? 10;
}
public function getSpikeWindowMinutes(): int
{
return $this->config['window_minutes'] ?? 5;
}
}