laravel使用加载进行优化

两种方式:

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');
原文地址:https://www.cnblogs.com/lxwphp/p/15454175.html