I've got this query:
$query = QueryBuilder::for(Advertisement::class)
->with('locations');
The locations method on Advertisement looks like this:
public function locations()
{
return $this->belongsToMany(Location::class, 'advertisement_locations', 'advertisement_id', 'location_id');
}
So a advertisements belongsToMany
locations in between is a pivot table called advertisement_locations
.
Now I would only get the advertisements between a given long
and latitude
that's on the locations
table.
How could I do this?