'int', 'customer_id' => 'int', 'lead_id' => 'int', 'is_answer' => 'bool', 'reply_id' => 'int', 'send' => 'bool', 'fail' => 'bool' ]; protected $dates = [ 'sent_at', 'scheduled_at', 'delivered_at' ]; protected $fillable = [ 'booking_id', 'customer_id', 'lead_id', 'is_answer', 'reply_id', 'email', 'subject', 'message', 'send', 'fail', 'error', 'sent_at', 'scheduled_at', 'delivered_at' ]; public function booking() { return $this->belongsTo(Booking::class); } public function customer() { return $this->belongsTo(Customer::class); } public function customer_mail() { return $this->belongsTo(CustomerMail::class, 'reply_id'); } public function lead() { return $this->belongsTo(Lead::class); } public function customer_files() { return $this->hasMany(CustomerFile::class); } public function customer_mails() { return $this->hasMany(CustomerMail::class, 'reply_id'); } 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()); } }