'int', 'from_user_id' => 'int', 'to_user_id' => 'int', 'show' => 'bool', 'important' => 'bool' ]; protected $dates = [ 'edit_at' ]; protected $fillable = [ 'travel_user_booking_fewo_id', 'from_user_id', 'to_user_id', 'message', 'show', 'important', 'edit_at' ]; public function travel_user_booking_fewo() { return $this->belongsTo(TravelUserBookingFewo::class); } public function to_user() { return $this->belongsTo(User::class, 'to_user_id'); } public function from_user() { return $this->belongsTo(User::class, 'from_user_id'); } public function getName(){ if($this->from_user){ if($this->from_user->sf_guard_user){ return $this->from_user->sf_guard_user->first_name." ".$this->from_user->sf_guard_user->last_name; }else{ $this->from_user->name; } } } public function getSmallerMessage($max = 500){ $ret = substr($this->message, 0, $max); if(strlen($this->message) > 500){ $ret .= " ..."; } return $ret; } }