phase 8 and 9

This commit is contained in:
Stefanescu Mihai
2026-03-19 18:42:19 +02:00
parent d75cabfeec
commit 82ebb697f3
94 changed files with 4498 additions and 749 deletions
+58
View File
@@ -0,0 +1,58 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Alert extends Model
{
use HasFactory;
protected $fillable = [
'website_id',
'name',
'metric',
'condition',
'threshold',
'period',
'channel',
'is_active',
'last_triggered_at',
];
protected function casts(): array
{
return [
'threshold' => 'decimal:2',
'is_active' => 'boolean',
'last_triggered_at' => 'datetime',
];
}
public function website(): BelongsTo
{
return $this->belongsTo(Website::class);
}
public function notifications(): HasMany
{
return $this->hasMany(AlertNotification::class);
}
public static array $metrics = [
'page_views' => 'Page Views',
'visitors' => 'Unique Visitors',
'sessions' => 'Sessions',
'bounce_rate' => 'Bounce Rate',
];
public static array $conditions = [
'above' => 'goes above',
'below' => 'drops below',
'change_up' => '% increase exceeds',
'change_down' => '% decrease exceeds',
];
}