Files
mohmdsdgandCursor 1c8ab4b725 feat(schedule): add schedule:bootstrap and minute-precise automation runs
Install per-module schedule:run cron from artisan, store sms/in_app send minutes, and match scheduled triggers at exact HH:mm Tehran time.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-24 22:13:06 +03:30

75 lines
1.8 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class Automation extends Model
{
use SoftDeletes;
protected $fillable = [
'name',
'code',
'is_active',
'starts_at',
'ends_at',
'sms_send_hour',
'sms_send_minute',
'in_app_send_hour',
'in_app_send_minute',
'trigger_type',
'trigger_config',
'last_anchor_price',
'conditions',
'channels',
'title',
'body',
'cooldown_hours',
'max_sends',
'logic_fingerprint',
'sent_count',
'failed_count',
'last_sms_run_at',
'last_in_app_run_at',
'created_by',
];
protected $casts = [
'is_active' => 'boolean',
'starts_at' => 'datetime',
'ends_at' => 'datetime',
'trigger_config' => 'array',
'conditions' => 'array',
'channels' => 'array',
'last_anchor_price' => 'float',
'sms_send_hour' => 'integer',
'sms_send_minute' => 'integer',
'in_app_send_hour' => 'integer',
'in_app_send_minute' => 'integer',
'cooldown_hours' => 'integer',
'max_sends' => 'integer',
'sent_count' => 'integer',
'failed_count' => 'integer',
'last_sms_run_at' => 'datetime',
'last_in_app_run_at' => 'datetime',
];
public function sends(): HasMany
{
return $this->hasMany(AutomationSend::class);
}
public function delayedJobs(): HasMany
{
return $this->hasMany(AutomationDelayedJob::class);
}
public function usesChannel(string $channel): bool
{
return in_array($channel, $this->channels ?? [], true);
}
}