You've already forked Atomcms-edit
Initial commit
This commit is contained in:
Executable
+59
@@ -0,0 +1,59 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user