讨论数量:
@DianWang 这选中的部分SQL
语句是通过预加载的查询语句,如果加上了分页,那显示Topic
的数据是不是不全了。
$topics = Topic::with('user', 'category')->paginate();
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
{
$page = $page ?: Paginator::resolveCurrentPage($pageName);
$perPage = $perPage ?: $this->model->getPerPage();
$results = ($total = $this->toBase()->getCountForPagination())
? $this->forPage($page, $perPage)->get($columns)
: $this->model->newCollection();
return $this->paginator($results, $total, $perPage, $page, [
'path' => Paginator::resolveCurrentPath(),
'pageName' => $pageName,
]);
}
$page = $page ?: Paginator::resolveCurrentPage($pageName);
如果不传入参数,会自己获取分页参数或者默认值
推荐文章: