class Pagination implements ArrayAccess, Countable, IteratorAggregate (View source)

Methods

__construct(int $next, int $previous, int $total, int $perPage, int $current, Collection $data)

Pagination constructor.

setBaseUrl(string $url)

Set the base URL for pagination links.

string|null
getBaseUrl()

Get the base URL for pagination links.

setPageParam(string $name)

Set the page query parameter name.

string
getPageParam()

Get the page query parameter name.

withQueryParams(array $params)

Add query parameters to the pagination URLs.

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.

getIterator()

Get an iterator for the items.

Details

__construct(int $next, int $previous, int $total, int $perPage, int $current, Collection $data)

Pagination constructor.

Parameters

int $next

The next page number.

int $previous

The previous page number.

int $total

The total number of items.

int $perPage

The number of items per page.

int $current

The current page number.

Collection $data

The collection of items for the current page.

Pagination setBaseUrl(string $url)

Set the base URL for pagination links.

Parameters

string $url

Return Value

Pagination

string|null getBaseUrl()

Get the base URL for pagination links.

Return Value

string|null

Pagination setPageParam(string $name)

Set the page query parameter name.

Parameters

string $name

Return Value

Pagination

string getPageParam()

Get the page query parameter name.

Return Value

string

Pagination withQueryParams(array $params)

Add query parameters to the pagination URLs.

Parameters

array $params

Return Value

Pagination

Pagination setQueryParams(array $params)

Set query parameters for the pagination URLs (replaces existing).

Parameters

array $params

Return Value

Pagination

array getQueryParams()

Get the query parameters.

Return Value

array

int next()

Get the next page number.

Return Value

int

bool hasNext()

Check if there is a next page.

Return Value

bool

int perPage()

Get the number of items per page.

Return Value

int

int previous()

Get the previous page number.

Return Value

int

bool hasPrevious()

Check if there is a previous page.

Return Value

bool

int current()

Get the current page number.

Return Value

int

Collection items()

Get the collection of items for the current page.

Return Value

Collection

int total()

Get the total number of items.

Return Value

int

int totalPages()

Get the total number of pages.

Return Value

int

bool hasPages()

Check if there are multiple pages.

Return Value

bool

bool onFirstPage()

Check if currently on the first page.

Return Value

bool

bool onLastPage()

Check if currently on the last page.

Return Value

bool

bool isEmpty()

Check if the pagination has no items.

Return Value

bool

bool isNotEmpty()

Check if the pagination has items.

Return Value

bool

int count()

Get the number of items on the current page.

Return Value

int

int firstItem()

Get the "index" of the first item being paginated (1-indexed).

Return Value

int

int lastItem()

Get the "index" of the last item being paginated (1-indexed).

Return Value

int

array toArray()

Get the pagination data as an array.

Return Value

array

string toJson(int $options = 0)

Convert the pagination to JSON.

Parameters

int $options

Return Value

string

string|null url(int $page)

Build a URL for a specific page number.

Parameters

int $page

Return Value

string|null

string|null nextPageUrl()

Get the URL for the next page.

Return Value

string|null

string|null previousPageUrl()

Get the URL for the previous page.

Return Value

string|null

string|null firstPageUrl()

Get the URL for the first page.

Return Value

string|null

string|null lastPageUrl()

Get the URL for the last page.

Return Value

string|null

array getUrlRange(int $onEachSide = 3)

Get an array of URLs for a range of pages.

Parameters

int $onEachSide

Number of links on each side of current page

Return Value

array

Get pagination links data for rendering.

Parameters

int $onEachSide

Number of links on each side of current page

Return Value

array

bool offsetExists(mixed $offset)

Determine if an item exists at an offset.

Parameters

mixed $offset

Return Value

bool

mixed offsetGet(mixed $offset)

Get an item at a given offset.

Parameters

mixed $offset

Return Value

mixed

void offsetSet(mixed $offset, mixed $value)

Set the item at a given offset.

Parameters

mixed $offset
mixed $value

Return Value

void

void offsetUnset(mixed $offset)

Unset the item at a given offset.

Parameters

mixed $offset

Return Value

void

Traversable getIterator()

Get an iterator for the items.

Return Value

Traversable