You've already forked Atomcms-edit
60 lines
1.2 KiB
PHP
Executable File
60 lines
1.2 KiB
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models\Miscellaneous;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class AlertLog extends Model
|
|
{
|
|
#[\Override]
|
|
protected $fillable = [
|
|
'type',
|
|
'severity',
|
|
'message',
|
|
'context',
|
|
'sent_via_email',
|
|
'sent_via_discord',
|
|
'is_read',
|
|
'read_at',
|
|
];
|
|
|
|
#[\Override]
|
|
protected $casts = [
|
|
'context' => 'array',
|
|
'sent_via_email' => 'boolean',
|
|
'sent_via_discord' => 'boolean',
|
|
'is_read' => 'boolean',
|
|
'read_at' => 'datetime',
|
|
];
|
|
|
|
public function markAsRead(): void
|
|
{
|
|
$this->update([
|
|
'is_read' => true,
|
|
'read_at' => now(),
|
|
]);
|
|
}
|
|
|
|
public function scopeUnread($query)
|
|
{
|
|
return $query->where('is_read', false);
|
|
}
|
|
|
|
public function scopeByType($query, string $type)
|
|
{
|
|
return $query->where('type', $type);
|
|
}
|
|
|
|
public function scopeBySeverity($query, string $severity)
|
|
{
|
|
return $query->where('severity', $severity);
|
|
}
|
|
|
|
public function scopeCritical($query)
|
|
{
|
|
return $query->where('severity', 'critical');
|
|
}
|
|
}
|