为了举例说明,假设我有以下内容,其中为每个人都设置了一个帽子的关系。
$people = People::join('hat')->get();
如何筛选出帽子是红色的人?
我尝试了以下方法:
$people = People::join('hat')
->where('hat.colour', 'red')
->get();
...但目前为止没有运气。
干杯
->whereHas()
进行过滤。如果可以的话,请展示您的模型。 - Tim Lewis