当前位置 : 主页 > 网络编程 > PHP >

laravel 分页

来源:互联网 收集:自由互联 发布时间:2021-06-28
gistfile1.txt public function paginate($perPage = null, $pageName = 'page', $page = null) { $engine = $this-engine(); $page = $page ?: Paginator::resolveCurrentPage($pageName); $perPage = $perPage ?: $this-model-getPerPage(); $results = Col
gistfile1.txt
public function paginate($perPage = null, $pageName = 'page', $page = null)
    {
        $engine = $this->engine();

        $page = $page ?: Paginator::resolveCurrentPage($pageName);

        $perPage = $perPage ?: $this->model->getPerPage();

        $results = Collection::make($engine->map(
            $rawResults = $engine->paginate($this, $perPage, $page), $this->model
        ));

        $paginator = (new LengthAwarePaginator($results, $engine->getTotalCount($rawResults), $perPage, $page, [
            'path' => Paginator::resolveCurrentPath(),
            'pageName' => $pageName,
        ]));

        return $paginator->appends('query', $this->query);
    }
网友评论