'Reisender', 1 => 'Agentur', 2 => 'Flug', 3 => 'Versicherung', 11 => 'Entwurf', 12 => 'Papierkorb', ]; protected $casts = [ 'booking_id' => 'int', 'customer_id' => 'int', 'lead_id' => 'int', 'is_answer' => 'bool', 'reply_id' => 'int', 'dir' => 'int', 'subdir' => 'int', 'travel_country_id' => 'int', 'draft' => 'bool', 'important' => 'bool', 'send' => 'bool', 'fail' => 'bool', 'recipient' => 'array', 'forward' => 'array', 'cc' => 'array', 'bcc' => 'array' ]; protected $dates = [ 'sent_at', 'scheduled_at', 'delivered_at' ]; protected $fillable = [ 'booking_id', 'customer_id', 'lead_id', 'is_answer', 'reply_id', 'email', 'recipient', 'cc', 'bcc', 'subject', 'message', 'dir', 'subdir', 'travel_country_id', 'draft', 'important', 'send', 'fail', 'error', 'forward', '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 travel_country() { return $this->belongsTo(TravelCountry::class); } 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 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 customer_mail_deep($deep = 0){ if($this->customer_mail){ $deep = $this->customer_mail->customer_mail_deep(++$deep); } return $deep; } 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(); } } }