两种方式:
1.使用:with
$posts=Post::orderby('created_at','desc')->withCount(['comments','zans'])->with('user')->paginate(5);
2.使用:load
$posts=Post::orderby('created_at','desc')->withCount(['comments','zans'])->paginate(5);
$posts->load('user');
两种方式:
1.使用:with
$posts=Post::orderby('created_at','desc')->withCount(['comments','zans'])->with('user')->paginate(5);
2.使用:load
$posts=Post::orderby('created_at','desc')->withCount(['comments','zans'])->paginate(5);
$posts->load('user');
文章来源: blog.csdn.net,作者:lxw1844912514,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/lxw1844912514/article/details/100027819
评论(0)