This commit is contained in:
Stefanescu Mihai
2026-03-19 19:47:06 +02:00
parent e8d2728d57
commit eb735a9a98
19 changed files with 860 additions and 9 deletions
+42
View File
@@ -0,0 +1,42 @@
<?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;
}
}