2026-05-24 12:17:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
2026-06-10 20:26:50 +00:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
2026-05-24 12:17:19 +00:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
|
|
|
|
|
class AutomationNodeState extends Model
|
|
|
|
|
{
|
2026-06-10 20:26:50 +00:00
|
|
|
use HasFactory;
|
2026-05-24 12:17:19 +00:00
|
|
|
use HasUuids;
|
|
|
|
|
|
|
|
|
|
protected $guarded = [];
|
|
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'data' => 'array',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function automation(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Automation::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Idempotent lookup for the state row of a given node within an automation,
|
|
|
|
|
* creating an empty row on first access. Use this in poll/fire actions that
|
|
|
|
|
* need to read or update an internal watermark.
|
|
|
|
|
*/
|
|
|
|
|
public static function for(string $automationId, string $nodeId): self
|
|
|
|
|
{
|
|
|
|
|
return self::firstOrCreate(
|
|
|
|
|
['automation_id' => $automationId, 'node_id' => $nodeId],
|
|
|
|
|
['data' => []],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|