两种方式:
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');