我想限制一个多对多关系,该多对多关系是由位于数据透视表中的数据加载的.
表_a
表_B
table_pivot (connects 表_a and 表_B many-to-many)
查询应返回具有立即加载的TableB的TableA,但仅当TABLE_PIVET.ACTIVE=TRUE时.
我try 了以下几种方法:
TableA::with(['表_B' => function ($query) {
$query->where('table_pivot.active', true);
// not sure how to address table_pivot here in the right way
}]);
所有模型都是以推荐的方式设置的(BelongsToMany关系等).
谢谢你在这方面的任何提示.