class LengthAwarePaginator implements Arrayable, JsonSerializable (View source)

Traits

Methods

mixed
forwardCallTo(object $object, string $method, array $parameters)

Forward a method call to the given object.

static 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.

int|null
calculateTo()

Calculate the "to" index for the current page.

array
jsonSerialize()

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.

Parameters

object $object
string $method
array $parameters

Return Value

mixed

static protected never throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

Parameters

string $method

Return Value

never

__construct(Collection $items, int $total, int $perPage, int $currentPage = 1, string $path = '', array $query = [], string $pageName = 'page')

Constructor.

Parameters

Collection $items
int $total
int $perPage
int $currentPage
string $path
array $query
string $pageName

mixed __call(string $method, array $parameters)

Handle dynamic method calls on the paginator.

Parameters

string $method
array $parameters

Return Value

mixed

Collection items()

Get the items being paginated.

Return Value

Collection

int total()

Get the total number of items.

Return Value

int

int perPage()

Get the number of items per page.

Return Value

int

int currentPage()

Get the current page number.

Return Value

int

int lastPage()

Get the last page (total pages).

Return Value

int

bool hasPages()

Determine if there are enough items to split into multiple pages.

Return Value

bool

bool hasMorePages()

Determine if there is a next page.

Return Value

bool

string url(int $page)

Generate the URL for a given page.

Parameters

int $page

Return Value

string

string|null nextPageUrl()

Get the URL for the next page, or null if none.

Return Value

string|null

string|null previousPageUrl()

Get the URL for the previous page, or null if none.

Return Value

string|null

array toArray()

Get the array representation of the paginator.

Return Value

array

protected int|null calculateTo()

Calculate the "to" index for the current page.

Return Value

int|null

array jsonSerialize()

Get the JSON representation of the paginator.

Return Value

array