added automation
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?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',
|
||||
'in_app_send_hour',
|
||||
'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',
|
||||
'in_app_send_hour' => '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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user