- Added new automation-related routes and controllers for managing automations. - Introduced automation nodes in the UI with distinct styles and interactions. - Updated sidebar to include navigation for automations. - Enhanced post creation logic to support automation metadata. - Refactored content type and platform enums into types for better type safety. - Added localization for automation-related terms in English, Spanish, and Portuguese. - Improved error handling in various components to accommodate new features.
38 lines
928 B
PHP
38 lines
928 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class AutomationNodeState extends Model
|
|
{
|
|
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' => []],
|
|
);
|
|
}
|
|
}
|