belongsTo('App\Location'); } public function endLocation() { return $this->belongsTo('App\Location'); } public function prices() { return $this->hasMany('App\Price'); } public function getTitleAttribute() { return $this->startLocation->title . ' - ' . $this->endLocation->title; } public function price($value) { return $this->prices()->where('vehicle_id', $value)->first() ? : new Route; } }