LengthAwarePaginator
class LengthAwarePaginator extends AbstractPaginator implements Arrayable, ArrayAccess, Countable, IteratorAggregate, Jsonable, LengthAwarePaginator (View source)
Properties
protected Collection | $items | All of the items being paginated. | from AbstractPaginator |
protected int | $perPage | The number of items to be shown per page. | from AbstractPaginator |
protected int | $currentPage | The current page being "viewed". | from AbstractPaginator |
protected string | $path | The base path to assign to all URLs. | from AbstractPaginator |
protected array | $query | The query parameters to add to all URLs. | from AbstractPaginator |
protected string|null | $fragment | The URL fragment to add to all URLs. | from AbstractPaginator |
protected string | $pageName | The query string variable used to store the page. | from AbstractPaginator |
static protected Closure | $currentPathResolver | The current page resolver callback. | from AbstractPaginator |
static protected Closure | $currentPageResolver | The current page resolver callback. | from AbstractPaginator |
static protected Closure | $presenterResolver | The default presenter resolver. | from AbstractPaginator |
protected int | $total | The total number of items before slicing. | |
protected int | $lastPage | The last available page. |
Methods
Determine if the given value is a valid page number.
Get / set the URL fragment to be appended to URLs.
Add a set of query string values to the paginator.
Add a query string value to the paginator.
Determine if there are enough items to split into multiple pages.
Resolve the current request path or return the default value.
Resolve the current page or return the default value.
Set the query string variable used to store the page.
Make dynamic calls into the collection.
Render the contents of the paginator when casting to string.
Create a new paginator instance.
Get the current page for the request.
Get the URL for the next page.
Determine if there are more items in the data source.
Get the total number of items being paginated.
Get the last page.
Get the instance as an array.
Convert the object to its JSON representation.
Details
in AbstractPaginator at line 84
protected bool
isValidPageNumber(int $page)
Determine if the given value is a valid page number.
in AbstractPaginator at line 96
string
getUrlRange(int $start, int $end)
Create a range of pagination URLs.
in AbstractPaginator at line 114
string
url(int $page)
Get a URL for a given page number.
in AbstractPaginator at line 138
string|null
previousPageUrl()
Get the URL for the previous page.
in AbstractPaginator at line 152
$this|string|null
fragment(string|null $fragment = null)
Get / set the URL fragment to be appended to URLs.
in AbstractPaginator at line 168
$this
appends(array|string $key, string|null $value = null)
Add a set of query string values to the paginator.
in AbstractPaginator at line 181
protected $this
appendArray(array $keys)
Add an array of query string values.
in AbstractPaginator at line 198
$this
addQuery(string $key, string $value)
Add a query string value to the paginator.
in AbstractPaginator at line 213
protected string
buildFragment()
Build the full fragment portion of a URL.
in AbstractPaginator at line 223
array
items()
Get the slice of items being paginated.
in AbstractPaginator at line 233
int
firstItem()
Get the number of the first item in the slice.
in AbstractPaginator at line 243
int
lastItem()
Get the number of the last item in the slice.
in AbstractPaginator at line 253
int
perPage()
Get the number of items shown per page.
in AbstractPaginator at line 263
int
currentPage()
Get the current page.
in AbstractPaginator at line 273
bool
hasPages()
Determine if there are enough items to split into multiple pages.
in AbstractPaginator at line 284
static string
resolveCurrentPath(string $default = '/')
Resolve the current request path or return the default value.
in AbstractPaginator at line 300
static void
currentPathResolver(Closure $resolver)
Set the current request path resolver callback.
in AbstractPaginator at line 311
static int
resolveCurrentPage(int $default = 1)
Resolve the current page or return the default value.
in AbstractPaginator at line 327
static void
currentPageResolver(Closure $resolver)
Set the current page resolver callback.
in AbstractPaginator at line 338
static void
presenter(Closure $resolver)
Set the default Presenter resolver.
in AbstractPaginator at line 349
$this
setPageName(string $name)
Set the query string variable used to store the page.
in AbstractPaginator at line 362
$this
setPath(string $path)
Set the base path to assign to all URLs.
in AbstractPaginator at line 374
ArrayIterator
getIterator()
Get an iterator for the items.
in AbstractPaginator at line 384
bool
isEmpty()
Determine if the list of items is empty or not.
in AbstractPaginator at line 394
int
count()
Get the number of items for the current page.
in AbstractPaginator at line 404
Collection
getCollection()
Get the paginator's underlying collection.
in AbstractPaginator at line 415
bool
offsetExists(mixed $key)
Determine if the given item exists.
in AbstractPaginator at line 426
mixed
offsetGet(mixed $key)
Get the item at the given offset.
in AbstractPaginator at line 438
void
offsetSet(mixed $key, mixed $value)
Set the item at the given offset.
in AbstractPaginator at line 449
void
offsetUnset(mixed $key)
Unset the item at the given key.
in AbstractPaginator at line 461
mixed
__call(string $method, array $parameters)
Make dynamic calls into the collection.
in AbstractPaginator at line 471
string
__toString()
Render the contents of the paginator when casting to string.
at line 38
void
__construct(mixed $items, int $total, int $perPage, int|null $currentPage = null, array $options = [])
Create a new paginator instance.
at line 60
protected int
setCurrentPage(int $currentPage, int $lastPage)
Get the current page for the request.
at line 80
string|null
nextPageUrl()
Get the URL for the next page.
at line 93
bool
hasMorePages()
Determine if there are more items in the data source.
at line 103
int
total()
Get the total number of items being paginated.
at line 113
int
lastPage()
Get the last page.
at line 124
string
render(Presenter $presenter = null)
Render the paginator using the given presenter.
at line 141
array
toArray()
Get the instance as an array.
at line 162
string
toJson(int $options)
Convert the object to its JSON representation.