Laravel有条件地雄辩许多

时间:2018-09-26 09:03:24

标签: php laravel-5

我有select geomfromtext(CONCAT('polygon(',GROUP_CONCAT(a.latitude,' ',a.longitude),'11.12345 66.65432)')) FROM GeometryTable a 个关系。假设我正在使用many to manyfoo

bar

如何仅显示具有class Foo extends Model { public function bars() { return $this->belongsToMany(Bar::class); } } class Bar extends Model { public function foos() { return $this->belongsToMany(Foo::class); } } 的{​​{1}},因此不会显示与Foo不相关的Bar记录?...

1 个答案:

答案 0 :(得分:0)

您可以使用has方法:https://laravel.com/docs/5.7/eloquent-relationships#querying-relationship-existence

$foos = App\Foo::has('bars')->get();
相关问题