Pagination
class Pagination implements ArrayAccess, Countable, IteratorAggregate (View source)
Methods
Pagination constructor.
Set the base URL for pagination links.
Get the base URL for pagination links.
Set the page query parameter name.
Get the page query parameter name.
Add query parameters to the pagination URLs.
Set query parameters for the pagination URLs (replaces existing).
Get the query parameters.
Get the next page number.
Check if there is a next page.
Get the number of items per page.
Get the previous page number.
Check if there is a previous page.
Get the current page number.
Get the collection of items for the current page.
Get the total number of items.
Get the total number of pages.
Check if there are multiple pages.
Check if currently on the first page.
Check if currently on the last page.
Check if the pagination has no items.
Check if the pagination has items.
Get the number of items on the current page.
Get the "index" of the first item being paginated (1-indexed).
Get the "index" of the last item being paginated (1-indexed).
Get the pagination data as an array.
Convert the pagination to JSON.
Build a URL for a specific page number.
Get the URL for the next page.
Get the URL for the previous page.
Get the URL for the first page.
Get the URL for the last page.
Get an array of URLs for a range of pages.
Get pagination links data for rendering.
Determine if an item exists at an offset.
Get an item at a given offset.
Set the item at a given offset.
Unset the item at a given offset.
Get an iterator for the items.
Details
__construct(int $next, int $previous, int $total, int $perPage, int $current, Collection $data)
Pagination constructor.
Pagination
setBaseUrl(string $url)
Set the base URL for pagination links.
string|null
getBaseUrl()
Get the base URL for pagination links.
Pagination
setPageParam(string $name)
Set the page query parameter name.
string
getPageParam()
Get the page query parameter name.
Pagination
withQueryParams(array $params)
Add query parameters to the pagination URLs.
Pagination
setQueryParams(array $params)
Set query parameters for the pagination URLs (replaces existing).
array
getQueryParams()
Get the query parameters.
int
next()
Get the next page number.
bool
hasNext()
Check if there is a next page.
int
perPage()
Get the number of items per page.
int
previous()
Get the previous page number.
bool
hasPrevious()
Check if there is a previous page.
int
current()
Get the current page number.
Collection
items()
Get the collection of items for the current page.
int
total()
Get the total number of items.
int
totalPages()
Get the total number of pages.
bool
hasPages()
Check if there are multiple pages.
bool
onFirstPage()
Check if currently on the first page.
bool
onLastPage()
Check if currently on the last page.
bool
isEmpty()
Check if the pagination has no items.
bool
isNotEmpty()
Check if the pagination has items.
int
count()
Get the number of items on the current page.
int
firstItem()
Get the "index" of the first item being paginated (1-indexed).
int
lastItem()
Get the "index" of the last item being paginated (1-indexed).
array
toArray()
Get the pagination data as an array.
string
toJson(int $options = 0)
Convert the pagination to JSON.
string|null
url(int $page)
Build a URL for a specific page number.
string|null
nextPageUrl()
Get the URL for the next page.
string|null
previousPageUrl()
Get the URL for the previous page.
string|null
firstPageUrl()
Get the URL for the first page.
string|null
lastPageUrl()
Get the URL for the last page.
array
getUrlRange(int $onEachSide = 3)
Get an array of URLs for a range of pages.
array
links(int $onEachSide = 3)
Get pagination links data for rendering.
bool
offsetExists(mixed $offset)
Determine if an item exists at an offset.
mixed
offsetGet(mixed $offset)
Get an item at a given offset.
void
offsetSet(mixed $offset, mixed $value)
Set the item at a given offset.
void
offsetUnset(mixed $offset)
Unset the item at a given offset.
Traversable
getIterator()
Get an iterator for the items.