Since three days I'm working on following problem:
protected function getTableQuery(): Builder
{
return User::
where('age','>',21)
->AppendDistanceTo(
$this->city->geo->long,
$this->city->geo->lat,
**lo**,
**la**,
);
}
The Model User has user_id and a id for the city city_id.
In the model City there is longitude and latitude for each city_id. How can I get the longitude and latitude in the query above, für lo and la from the related Model?
Thank you very much for helping!
I want to show the distance from a selected city ( $this->city->geo->long,$this->city->geo->lat)
to the city, where the user lives.