两种方式:
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');
赞赏码
非学,无以致疑;非问,无以广识