Paginator
class Paginator implements ArrayableInterface, ArrayAccess, Countable, IteratorAggregate, JsonableInterface (View source)
Properties
protected Factory | $factory | The pagination factory. |
|
protected array | $items | The items being paginated. |
|
protected int | $total | The total number of items. |
|
protected bool | $hasMore | Indicates if a pagination doing "quick" pagination has more items. |
|
protected int | $perPage | The amount of items to show per page. |
|
protected int | $currentPage | Get the current page for the request. |
|
protected | $lastPage | Get the last available page number. |
|
protected int | $from | The number of the first item in this range. |
|
protected int | $to | The number of the last item in this range. |
|
protected array | $query | All of the additional query string values. |
|
protected string | $fragment | The fragment to be appended to all URLs. |
Methods
Create a new Paginator instance.
Setup the pagination context (current and last page).
Calculate the current and last pages for this instance.
Calculate the first and last item number for this instance.
Get the current page for the request.
Determine if the given value is a valid page number.
Get a URL for a given page number.
Get / set the URL fragment to be appended to URLs.
Build the full fragment portion of a URL.
Add a query string value to the paginator.
Add an array of query string values.
Add a query string value to the paginator.
Determine if the paginator is doing "quick" pagination.
Get the current page for the request.
Get the last page that should be available.
Get the number of the first item on the paginator.
Get the number of the last item on the paginator.
Get the number of items to be displayed per page.
Get a collection instance containing the items.
Get the items being paginated.
Set the items being paginated.
Get the total number of items in the collection.
Set the base URL in use by the paginator.
Get the pagination factory.
Get an iterator for the items.
Determine if the list of items is empty or not.
Get the number of items for the current page.
Determine if the given item exists.
Get the item at the given offset.
Set the item at the given offset.
Unset the item at the given key.
Get the instance as an array.
Convert the object to its JSON representation.
Call a method on the underlying Collection
Details
void
__construct(Factory $factory, array $items, int $total, int|null $perPage = null)
Create a new Paginator instance.
$this
setupPaginationContext()
Setup the pagination context (current and last page).
protected void
calculateCurrentAndLastPages()
Calculate the current and last pages for this instance.
protected void
calculateItemRanges()
Calculate the first and last item number for this instance.
protected int
calculateCurrentPage(int $lastPage)
Get the current page for the request.
protected bool
isValidPageNumber(int $page)
Determine if the given value is a valid page number.
View
links(string $view = null)
Get the pagination links view.
string
getUrl(int $page)
Get a URL for a given page number.
$this|string
fragment(string|null $fragment = null)
Get / set the URL fragment to be appended to URLs.
protected string
buildFragment()
Build the full fragment portion of a URL.
$this
appends(string $key, string $value = null)
Add a query string value to the paginator.
protected $this
appendArray(array $keys)
Add an array of query string values.
$this
addQuery(string $key, string $value)
Add a query string value to the paginator.
bool
isQuickPaginating()
Determine if the paginator is doing "quick" pagination.
int
getCurrentPage(int|null $total = null)
Get the current page for the request.
int
getLastPage()
Get the last page that should be available.
int
getFrom()
Get the number of the first item on the paginator.
int
getTo()
Get the number of the last item on the paginator.
int
getPerPage()
Get the number of items to be displayed per page.
Collection
getCollection()
Get a collection instance containing the items.
array
getItems()
Get the items being paginated.
void
setItems(mixed $items)
Set the items being paginated.
int
getTotal()
Get the total number of items in the collection.
void
setBaseUrl(string $baseUrl)
Set the base URL in use by the paginator.
Factory
getFactory()
Get the pagination factory.
ArrayIterator
getIterator()
Get an iterator for the items.
bool
isEmpty()
Determine if the list of items is empty or not.
int
count()
Get the number of items for the current page.
bool
offsetExists(mixed $key)
Determine if the given item exists.
mixed
offsetGet(mixed $key)
Get the item at the given offset.
void
offsetSet(mixed $key, mixed $value)
Set the item at the given offset.
void
offsetUnset(mixed $key)
Unset the item at the given key.
array
toArray()
Get the instance as an array.
string
toJson(int $options = 0)
Convert the object to its JSON representation.
mixed
__call(string $method, array $arguments)
Call a method on the underlying Collection