start_location = $attributes['start_location']; $this->end_location = $attributes['end_location']; $this->date = isset($attributes['date']) ? $attributes['date'] : null; $this->people = isset($attributes['people']) ? $attributes['people'] : null; $this->type = isset($attributes['type']) ? $attributes['type'] : 'oneway'; } public function setStartLocationAttribute($value) { $this->attributes['start_location'] = $value; $this->attributes['start'] = Location::where('title', $value)->first(); } public function setEndLocationAttribute($value) { $this->attributes['end_location'] = $value; $this->attributes['end'] = Location::where('title', $value)->first(); } }