*/ protected $fillable = [ 'uuid', 'account_id', 'user_id', 'type', 'status', 'filesystem', 'filename', 'started_at', 'ended_at', ]; /** * The attributes that aren't mass assignable. * * @var array|bool */ protected $guarded = ['id']; /** * The attributes that should be mutated to dates. * * @var array */ protected $dates = [ 'started_at', 'ended_at', ]; /** * Get the account record associated with the import job. * * @return BelongsTo */ public function account() { return $this->belongsTo(Account::class); } /** * Get the user record associated with the import job. * * @return BelongsTo */ public function user() { return $this->belongsTo(User::class); } /** * Start the export job. * * @return void */ public function start(): void { $this->status = self::EXPORT_DOING; $this->started_at = now(); $this->save(); } /** * End the export job. * * @return void */ public function end(): void { $this->status = self::EXPORT_DONE; $this->ended_at = now(); $this->save(); $this->user->notify(new ExportAccountDone($this)); } }