| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\App\Models; |
| 4 |
|
| 5 |
use FluentCart\App\Services\PlanUpgradeService; |
| 6 |
use FluentCart\Framework\Database\Orm\Builder; |
| 7 |
use FluentCart\Framework\Support\Arr; |
| 8 |
|
| 9 |
/** |
| 10 |
* Meta Model - DB Model for Meta table |
| 11 |
* |
| 12 |
* Database Model |
| 13 |
* |
| 14 |
* @package FluentCart\App\Models |
| 15 |
* |
| 16 |
* @version 1.0.0 |
| 17 |
*/ |
| 18 |
class ScheduledAction extends Model |
| 19 |
{ |
| 20 |
protected $table = 'fct_scheduled_actions'; |
| 21 |
|
| 22 |
protected $primaryKey = 'id'; |
| 23 |
|
| 24 |
protected $guarded = ['id']; |
| 25 |
|
| 26 |
protected $fillable = [ |
| 27 |
'scheduled_at', |
| 28 |
'action', |
| 29 |
'status', |
| 30 |
'group', |
| 31 |
'object_id', |
| 32 |
'object_type', |
| 33 |
'completed_at', |
| 34 |
'retry_count', |
| 35 |
'data', |
| 36 |
'response_note', |
| 37 |
]; |
| 38 |
|
| 39 |
public function setDataAttribute($value) |
| 40 |
{ |
| 41 |
if (is_array($value) || is_object($value)) { |
| 42 |
$this->attributes['data'] = json_encode($value); |
| 43 |
} else { |
| 44 |
$this->attributes['data'] = $value; |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
public function getDataAttribute($value) |
| 49 |
{ |
| 50 |
|
| 51 |
$decoded = json_decode($value, true); |
| 52 |
|
| 53 |
if ($decoded && is_array($decoded)) { |
| 54 |
return $decoded; |
| 55 |
} |
| 56 |
|
| 57 |
return []; |
| 58 |
} |
| 59 |
|
| 60 |
} |
| 61 |
|