'int', 'customer_id' => 'int', 'is_answer' => 'bool', 'reply_id' => 'int', 'dir' => 'int', 'subdir' => 'int', 'draft' => 'bool', 'important' => 'bool', 'send' => 'bool', 'fail' => 'bool', 'recipient' => 'array', 'forward' => 'array', 'cc' => 'array', 'bcc' => 'array', 'sent_at' => 'datetime', 'scheduled_at' => 'datetime', 'delivered_at' => 'datetime', ]; protected $fillable = [ 'lead_id', 'customer_id', 'is_answer', 'reply_id', 'email', 'recipient', 'cc', 'bcc', 'subject', 'message', 'dir', 'subdir', 'draft', 'important', 'send', 'fail', 'error', 'forward', 'sent_at', 'scheduled_at', 'delivered_at' ]; public function customer() { return $this->belongsTo(Customer::class); } public function lead() { return $this->belongsTo(Lead::class); } public function lead_mail() { return $this->belongsTo(LeadMail::class, 'reply_id'); } public function lead_files() { return $this->hasMany(LeadFile::class); } public function getSentAtRaw(){ return $this->attributes['sent_at']; } public function getSentAtAttribute(){ if(!$this->attributes['sent_at']){ return ""; } return Carbon::parse($this->attributes['sent_at'])->format(\Util::formatDateTimeDB()); } public function getCreatedAtAttribute(){ if(!$this->attributes['created_at']){ return ""; } return Carbon::parse($this->attributes['created_at'])->format(\Util::formatDateTimeDB()); } public function setForwardMessage($forward = []) { if($forward && is_array($forward)){ if(isset($this->forward) && $this->forward){ $this->forward = array_merge($this->forward , $forward); }else{ $this->forward = $forward; } $this->save(); } } }