src/Lego/Operator/Query.php
public function paginate(
        $perPage = null,
        $columns = null,
        $pageName = null,
        $page = null,
        bool $lengthAware = true
    ) {
        $perPage = is_null($perPage) ? config('lego.paginator.per-page') : $perPage;
        $pageName = is_null($pageName) ? config('lego.paginator.page-name') : $pageName;
        $columns = is_null($columns) ? ['*'] : $columns;
        $page = $page ?: Request::query($pageName, 1);

        if ($lengthAware) {
            $this->paginator = $this->createLengthAwarePaginator($perPage, $columns, $pageName, $page);
        } else {
            $this->paginator = $this->createLengthNotAwarePaginator($perPage, $columns, $pageName, $page);
        }

        $this->paginator->setCollection(
            $this->paginator->getCollection()->map(function ($row) {
                return Finder::createStore($row);
            })
        );

        return $this->paginator;
    }
public function paginate(
        $perPage = null,
        $columns = null,
        $pageName = null,
        $page = null,
        bool $lengthAware = true
    ) {
        $perPage = is_null($perPage) ? config('lego.paginator.per-page') : $perPage;
        $pageName = is_null($pageName) ? config('lego.paginator.page-name') : $pageName;
        $columns = is_null($columns) ? ['*'] : $columns;
        $page = $page ?: Request::query($pageName, 1);

        if ($lengthAware) {
            $this->paginator = $this->createLengthAwarePaginator($perPage, $columns, $pageName, $page);
        } else {
            $this->paginator = $this->createLengthNotAwarePaginator($perPage, $columns, $pageName, $page);
        }

        $this->paginator->setCollection(
            $this->paginator->getCollection()->map(function ($row) {
                return Finder::createStore($row);
            })
        );

        return $this->paginator;
    }
public function paginate ( $ perPage = null , $ columns = null , $ pageName = null , $ page = null , bool $ lengthAware = true ) { $ perPage = is_null ( $ perPage ) ? config ( 'lego.paginator.per-page' ) : $ perPage ; $ pageName = is_null ( $ pageName ) ? config ( 'lego.paginator.page-name' ) : $ pageName ; $ columns = is_null ( $ columns ) ? [ '*' ] : $ columns ; $ page = $ page ? : Request :: query ( $ pageName , 1 ) ; if ( $ lengthAware ) { $ this -> paginator = $ this -> createLengthAwarePaginator ( $ perPage , $ columns , $ pageName , $ page ) ; } else { $ this -> paginator = $ this -> createLengthNotAwarePaginator ( $ perPage , $ columns , $ pageName , $ page ) ; } $ this -> paginator -> setCollection ( $ this -> paginator -> getCollection ( ) -> map ( function ( $ row ) { return Finder :: createStore ( $ row ) ; } ) ) ; return $ this -> paginator ; }
Paginator API.

@param int    $perPage     每页条数
@param array  $columns     需要的字段列表
@param string $pageName    分页的 GET 参数名称
@param int    $page        当前页码
@param bool   $lengthAware 是否需要查询总页数

@return AbstractPaginator|Store[]
Paginator API .