如何在话题列表中实现每条话题 附带 该话题的最新的 3 条评论并且展示在列表中?
$topics = Topic::with(['replies'=>function($query){
$query->orderBy('id');
}])->get();
加上take之后,replies=>null
$topics = Topic::with(['replies'=>function($query){
$query->orderBy('id')->take(3);
}])->get();
with里面不能加take方法吗?
推荐文章: