AbstractPaginator
abstract class AbstractPaginator implements CanBeEscapedWhenCastToString, Htmlable, Stringable mixin TKey,
Traits
Constants
| protected DEFAULT_VIEW |
The default pagination view name. |
| protected DEFAULT_SIMPLE_VIEW |
The default simple pagination view name. |
Properties
| protected TValue> | $items | All of the items being paginated. |
|
| protected int | $perPage | The number of items to be shown per page. |
|
| protected int | $currentPage | The current page being "viewed". |
|
| protected string | $path | The base path to assign to all URLs. |
|
| protected array<array-key, mixed> | $query | The query parameters to add to all URLs. |
|
| protected string|null | $fragment | The URL fragment to add to all URLs. |
|
| protected string | $pageName | The query string variable used to store the page. |
|
| protected bool | $escapeWhenCastingToString | Indicates that the paginator's string representation should be escaped when __toString is invoked. |
|
| int | $onEachSide | The number of links to display on each side of current page link. |
|
| protected array<string, mixed> | $options | The paginator options. |
|
| static protected Closure|null | $currentPathResolver | The current path resolver callback. |
|
| static protected Closure|null | $currentPageResolver | The current page resolver callback. |
|
| static protected Closure|null | $queryStringResolver | The query string resolver callback. |
|
| static protected Closure|null | $viewFactoryResolver | The view factory resolver callback. |
|
| static string | $defaultView | The default pagination view. |
|
| static string | $defaultSimpleView | The default "simple" pagination view. |
Methods
Forward a method call to the given object.
Forward a method call to the given object, returning $this if the forwarded call returned itself.
Throw a bad method call exception for the given method.
Call the given Closure with this instance then return the instance.
Create a new resource collection instance for the given resource.
Guess the resource collection for the items.
Get the resource class from the class attribute.
Get the resource collection class from the class attribute.
Render the paginator using the given view.
Determine if there are more items in the data source.
Determine if the given value is a valid page number.
Get the URL for the previous page.
Create a range of pagination URLs.
Get the URL for a given page number.
Get / set the URL fragment to be appended to URLs.
Add a set of query string values to the paginator.
Add an array of query string values.
Add all current query string values to the paginator.
Add a query string value to the paginator.
Build the full fragment portion of a URL.
Load a set of relationships onto the mixed relationship collection.
Load a set of relationship counts onto the mixed relationship collection.
Get the slice of items being paginated.
Get the number of the first item in the slice.
Get the number of the last item in the slice.
Transform each item in the slice of items using a callback.
Get the number of items shown per page.
Determine if there are enough items to split into multiple pages.
Determine if the paginator is on the first page.
Determine if the paginator is on the last page.
Get the current page.
Get the query string variable used to store the page.
Set the query string variable used to store the page.
Set the base path to assign to all URLs.
Set the base path to assign to all URLs.
Set the number of links to display on each side of current page link.
Get the base path for paginator generated URLs.
Resolve the current request path or return the default value.
Resolve the current page or return the default value.
Resolve the query string or return the default value.
Get an instance of the view factory from the resolver.
Set the default pagination view.
Set the default "simple" pagination view.
Indicate that Tailwind styling should be used for generated links.
Flush all static state.
Get an iterator for the items.
Determine if the list of items is empty.
Determine if the list of items is not empty.
Get the number of items for the current page.
Get the paginator's underlying collection.
Get the paginator options.
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.
Render the contents of the paginator to HTML.
Make dynamic calls into the collection.
Render the contents of the paginator when casting to a string.
Indicate that the paginator's string representation should be escaped when __toString is invoked.
Details
in
ForwardsCalls at line 22
protected mixed
forwardCallTo(mixed $object, string $method, array $parameters)
Forward a method call to the given object.
in
ForwardsCalls at line 52
protected mixed
forwardDecoratedCallTo(mixed $object, string $method, array $parameters)
Forward a method call to the given object, returning $this if the forwarded call returned itself.
in
ForwardsCalls at line 66
static protected never
throwBadMethodCallException(string $method)
Throw a bad method call exception for the given method.
in
Tappable at line 17
mixed
tap(callable|null $callback = null)
Call the given Closure with this instance then return the instance.
in
TransformsToResourceCollection at line 24
ResourceCollection
toResourceCollection(string|null $resourceClass = null)
Create a new resource collection instance for the given resource.
in
TransformsToResourceCollection at line 38
protected ResourceCollection
guessResourceCollection()
Guess the resource collection for the items.
in
TransformsToResourceCollection at line 93
protected string|null
resolveResourceFromAttribute(string $class)
Get the resource class from the class attribute.
in
TransformsToResourceCollection at line 112
protected string|null
resolveResourceCollectionFromAttribute(string $class)
Get the resource collection class from the class attribute.
at line 42
abstract Htmlable
render(string|null $view = null, array $data = [])
Render the paginator using the given view.
at line 47
abstract bool
hasMorePages()
Determine if there are more items in the data source.
at line 148
protected bool
isValidPageNumber(int $page)
Determine if the given value is a valid page number.
at line 156
string|null
previousPageUrl()
Get the URL for the previous page.
at line 170
array
getUrlRange(int $start, int $end)
Create a range of pagination URLs.
at line 180
string
url(int $page)
Get the URL for a given page number.
at line 206
AbstractPaginator|string|null
fragment(string|null $fragment = null)
Get / set the URL fragment to be appended to URLs.
at line 222
AbstractPaginator
appends(array|int|string|null $key, array|bool|float|int|string|null $value = null)
Add a set of query string values to the paginator.
at line 243
protected AbstractPaginator
appendArray(array $keys)
Add an array of query string values.
at line 257
AbstractPaginator
withQueryString()
Add all current query string values to the paginator.
at line 271
protected AbstractPaginator
addQuery(int|string $key, mixed $value)
Add a query string value to the paginator.
at line 283
protected string
buildFragment()
Build the full fragment portion of a URL.
at line 297
AbstractPaginator
loadMorph(string $relation, array $relations)
Load a set of relationships onto the mixed relationship collection.
at line 314
AbstractPaginator
loadMorphCount(string $relation, array $relations)
Load a set of relationship counts onto the mixed relationship collection.
at line 327
array
items()
Get the slice of items being paginated.
at line 335
int|null
firstItem()
Get the number of the first item in the slice.
at line 343
int|null
lastItem()
Get the number of the last item in the slice.
at line 358
AbstractPaginator
through(callable $callback)
Transform each item in the slice of items using a callback.
at line 368
int
perPage()
Get the number of items shown per page.
at line 376
bool
hasPages()
Determine if there are enough items to split into multiple pages.
at line 384
bool
onFirstPage()
Determine if the paginator is on the first page.
at line 392
bool
onLastPage()
Determine if the paginator is on the last page.
at line 400
int
currentPage()
Get the current page.
at line 408
string
getPageName()
Get the query string variable used to store the page.
at line 418
AbstractPaginator
setPageName(string $name)
Set the query string variable used to store the page.
at line 430
AbstractPaginator
withPath(string $path)
Set the base path to assign to all URLs.
at line 440
AbstractPaginator
setPath(string $path)
Set the base path to assign to all URLs.
at line 452
AbstractPaginator
onEachSide(int $count)
Set the number of links to display on each side of current page link.
at line 462
string|null
path()
Get the base path for paginator generated URLs.
at line 470
static string
resolveCurrentPath(string $default = '/')
Resolve the current request path or return the default value.
at line 485
static void
currentPathResolver(Closure $resolver)
Set the current request path resolver callback.
The resolver persists in a static property for the worker lifetime and runs on every subsequent paginator's path lookup.
at line 494
static int
resolveCurrentPage(string $pageName = 'page', int $default = 1)
Resolve the current page or return the default value.
at line 509
static void
currentPageResolver(Closure $resolver)
Set the current page resolver callback.
The resolver persists in a static property for the worker lifetime and runs on every subsequent paginator's page lookup.
at line 518
static string|array|null
resolveQueryString(string|array|null $default = null)
Resolve the query string or return the default value.
at line 533
static void
queryStringResolver(Closure $resolver)
Set with query string resolver callback.
The resolver persists in a static property for the worker lifetime and runs on every subsequent paginator's query-string lookup.
at line 542
static Factory
viewFactory()
Get an instance of the view factory from the resolver.
at line 553
static void
viewFactoryResolver(Closure $resolver)
Set the view factory resolver callback.
The resolver persists in a static property for the worker lifetime and runs on every subsequent paginator render.
at line 565
static void
defaultView(string $view)
Set the default pagination view.
The view name persists in a static property for the worker lifetime and applies to every subsequent paginator render.
at line 577
static void
defaultSimpleView(string $view)
Set the default "simple" pagination view.
The view name persists in a static property for the worker lifetime and applies to every subsequent simple-paginator render.
at line 589
static void
useTailwind()
Indicate that Tailwind styling should be used for generated links.
Sets the default view names in static properties for the worker lifetime; applies to every subsequent paginator render.
at line 601
static void
flushState()
Flush all static state.
at line 616
Traversable
getIterator()
Get an iterator for the items.
at line 624
bool
isEmpty()
Determine if the list of items is empty.
at line 632
bool
isNotEmpty()
Determine if the list of items is not empty.
at line 640
int
count()
Get the number of items for the current page.
at line 650
Collection
getCollection()
Get the paginator's underlying collection.
at line 667
AbstractPaginator
setCollection(Collection $collection)
Set the paginator's underlying collection.
at line 679
array
getOptions()
Get the paginator options.
at line 689
bool
offsetExists(TKey $offset)
Determine if the given item exists.
at line 700
mixed
offsetGet(TKey $offset)
Get the item at the given offset.
at line 711
void
offsetSet(null|TKey $offset, TValue $value)
Set the item at the given offset.
at line 721
void
offsetUnset(TKey $offset)
Unset the item at the given key.
at line 729
string
toHtml()
Render the contents of the paginator to HTML.
at line 741
mixed
__call(string $method, array $parameters)
Make dynamic calls into the collection.
at line 749
string
__toString()
Render the contents of the paginator when casting to a string.
at line 766
CanBeEscapedWhenCastToString
escapeWhenCastingToString(bool $escape = true)
Indicate that the paginator's string representation should be escaped when __toString is invoked.