Files
HickLab3D_Dashboard/app/Models/AlertState.php
T
HickmeisterandClaude Sonnet 5.5 ab1fdb961f
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 28s
Add notification inbox, toasts and alert scanner for orders, prints and filament
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-11 21:02:35 +01:00

41 lines
810 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Remembers what the alert scanner has already seen so each event notifies once.
*/
class AlertState extends Model
{
public $incrementing = false;
protected $primaryKey = 'key';
protected $keyType = 'string';
protected $fillable = ['key', 'state'];
protected function casts(): array
{
return ['state' => 'array'];
}
/**
* @return array<string, mixed>|null
*/
public static function read(string $key): ?array
{
return static::find($key)?->state;
}
/**
* @param array<string, mixed> $state
*/
public static function write(string $key, array $state): void
{
static::updateOrCreate(['key' => $key], ['state' => $state]);
}
}