LengthAwarePaginator
class LengthAwarePaginator implements Arrayable, JsonSerializable (View source)
Traits
Methods
Forward a method call to the given object.
Throw a bad method call exception for the given method.
Constructor.
Handle dynamic method calls on the paginator.
Get the items being paginated.
Get the total number of items.
Get the number of items per page.
Get the current page number.
Get the last page (total pages).
Determine if there are enough items to split into multiple pages.
Determine if there is a next page.
Generate the URL for a given page.
Get the URL for the next page, or null if none.
Get the URL for the previous page, or null if none.
Get the array representation of the paginator.
Calculate the "to" index for the current page.
Get the JSON representation of the paginator.
Details
protected mixed
forwardCallTo(object $object, string $method, array $parameters)
Forward a method call to the given object.
static protected never
throwBadMethodCallException(string $method)
Throw a bad method call exception for the given method.
__construct(Collection $items, int $total, int $perPage, int $currentPage = 1, string $path = '', array $query = [], string $pageName = 'page')
Constructor.
mixed
__call(string $method, array $parameters)
Handle dynamic method calls on the paginator.
Collection
items()
Get the items being paginated.
int
total()
Get the total number of items.
int
perPage()
Get the number of items per page.
int
currentPage()
Get the current page number.
int
lastPage()
Get the last page (total pages).
bool
hasPages()
Determine if there are enough items to split into multiple pages.
bool
hasMorePages()
Determine if there is a next page.
string
url(int $page)
Generate the URL for a given page.
string|null
nextPageUrl()
Get the URL for the next page, or null if none.
string|null
previousPageUrl()
Get the URL for the previous page, or null if none.
array
toArray()
Get the array representation of the paginator.
protected int|null
calculateTo()
Calculate the "to" index for the current page.
array
jsonSerialize()
Get the JSON representation of the paginator.