【发布时间】:2018-05-19 17:30:48
【问题描述】:
我有这个查询:
$query = QueryBuilder::for(Advertisement::class)
->with('locations');
广告的位置方法如下所示:
public function locations()
{
return $this->belongsToMany(Location::class, 'advertisement_locations', 'advertisement_id', 'location_id');
}
因此,介于两者之间的广告belongsToMany 位置是一个名为advertisement_locations 的数据透视表。
现在我只会获得long 和latitude 之间的广告,这些广告位于locations 表中。
我怎么能这样做?
【问题讨论】:
标签: php laravel eloquent query-builder