【发布时间】:2016-01-12 08:50:15
【问题描述】:
我有一个疑问:
Posts::whereHas('comments', function($query){
$query->where('name', 'like', 'asd');
})->with('comments')->get();
它返回所有具有名称为“asd”的 cmets 的帖子以及这些帖子的所有 cmets。我可以在 '::whereHas' 中为 'with' 方法使用上述约束,这样它就不会返回所有 cmets,而只返回符合要求的那些?还是我必须复制查询?
【问题讨论】: