29 lines
815 B
PHP
29 lines
815 B
PHP
<?php
|
|
|
|
namespace Modules\Automation\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
final class Automation extends Model
|
|
{
|
|
protected $fillable = ['name', 'description', 'trigger_type', 'trigger_config', 'status', 'stop_on_failure', 'run_count', 'last_ran_at', 'next_run_at', 'created_by'];
|
|
|
|
protected $casts = ['trigger_config' => 'array', 'stop_on_failure' => 'boolean', 'last_ran_at' => 'datetime', 'next_run_at' => 'datetime'];
|
|
|
|
public function steps(): HasMany
|
|
{
|
|
return $this->hasMany(AutomationStep::class)->orderBy('position');
|
|
}
|
|
|
|
public function runs(): HasMany
|
|
{
|
|
return $this->hasMany(AutomationRun::class);
|
|
}
|
|
|
|
public function isActive(): bool
|
|
{
|
|
return $this->status === 'active';
|
|
}
|
|
}
|