src/LinksTrait.php
protected function addPaginationLink($name, $url, array $queryParams, $offset, $limit)
    {
        if (! isset($queryParams['page']) || ! is_array($queryParams['page'])) {
            $queryParams['page'] = [];
        }

        $page = &$queryParams['page'];

        if (isset($page['number'])) {
            $page['number'] = floor($offset / $limit) + 1;

            if ($page['number'] <= 1) {
                unset($page['number']);
            }
        } else {
            $page['offset'] = $offset;

            if ($page['offset'] <= 0) {
                unset($page['offset']);
            }
        }

        if (isset($page['limit'])) {
            $page['limit'] = $limit;
        }

        $queryString = http_build_query($queryParams);

        $this->addLink($name, $url.($queryString ? '?'.$queryString : ''));
    }
protected function addPaginationLink($name, $url, array $queryParams, $offset, $limit)
    {
        if (! isset($queryParams['page']) || ! is_array($queryParams['page'])) {
            $queryParams['page'] = [];
        }

        $page = &$queryParams['page'];

        if (isset($page['number'])) {
            $page['number'] = floor($offset / $limit) + 1;

            if ($page['number'] <= 1) {
                unset($page['number']);
            }
        } else {
            $page['offset'] = $offset;

            if ($page['offset'] <= 0) {
                unset($page['offset']);
            }
        }

        if (isset($page['limit'])) {
            $page['limit'] = $limit;
        }

        $queryString = http_build_query($queryParams);

        $this->addLink($name, $url.($queryString ? '?'.$queryString : ''));
    }
protected function addPaginationLink ( $ name , $ url , array $ queryParams , $ offset , $ limit ) { if ( ! isset ( $ queryParams [ 'page' ] ) || ! is_array ( $ queryParams [ 'page' ] ) ) { $ queryParams [ 'page' ] = [ ] ; } $ page = & $ queryParams [ 'page' ] ; if ( isset ( $ page [ 'number' ] ) ) { $ page [ 'number' ] = floor ( $ offset / $ limit ) + 1 ; if ( $ page [ 'number' ] <= 1 ) { unset ( $ page [ 'number' ] ) ; } } else { $ page [ 'offset' ] = $ offset ; if ( $ page [ 'offset' ] <= 0 ) { unset ( $ page [ 'offset' ] ) ; } } if ( isset ( $ page [ 'limit' ] ) ) { $ page [ 'limit' ] = $ limit ; } $ queryString = http_build_query ( $ queryParams ) ; $ this -> addLink ( $ name , $ url . ( $ queryString ? '?' . $ queryString : '' ) ) ; }
Add a pagination link.

@param string $name The name of the link.
@param string $url The base URL for pagination links.
@param array $queryParams The query params provided in the request.
@param int $offset The offset to link to.
@param int $limit The current limit.

@return void
Add a pagination link .