AbstractPaginator
abstract class AbstractPaginator implements CanBeEscapedWhenCastToString, Htmlable, Stringable mixin TKey,
Traits
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<string, 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 15
mixed
tap(callable|null $callback = null)
Call the given Closure with this instance then return the instance.
in
TransformsToResourceCollection at line 25
ResourceCollection
toResourceCollection(string|null $resourceClass = null)
Create a new resource collection instance for the given resource.
in
TransformsToResourceCollection at line 39
protected ResourceCollection
guessResourceCollection()
Guess the resource collection for the items.
in
TransformsToResourceCollection at line 92
protected string|null
resolveResourceFromAttribute(string $class)
Get the resource class from the class attribute.
in
TransformsToResourceCollection at line 111
protected string|null
resolveResourceCollectionFromAttribute(string $class)
Get the resource collection class from the class attribute.
at line 36
abstract Htmlable
render(string|null $view = null, array $data = [])
Render the paginator using the given view.
at line 41
abstract bool
hasMorePages()
Determine if there are more items in the data source.
at line 132
protected bool
isValidPageNumber(int $page)
Determine if the given value is a valid page number.
at line 140
string|null
previousPageUrl()
Get the URL for the previous page.
at line 154
array
getUrlRange(int $start, int $end)
Create a range of pagination URLs.
at line 164
string
url(int $page)
Get the URL for a given page number.
at line 190
AbstractPaginator|string|null
fragment(string|null $fragment = null)
Get / set the URL fragment to be appended to URLs.
at line 206
AbstractPaginator
appends(array|string|null $key, array|string|null $value = null)
Add a set of query string values to the paginator.
at line 225
protected AbstractPaginator
appendArray(array $keys)
Add an array of query string values.
at line 239
AbstractPaginator
withQueryString()
Add all current query string values to the paginator.
at line 253
protected AbstractPaginator
addQuery(string $key, mixed $value)
Add a query string value to the paginator.
at line 265
protected string
buildFragment()
Build the full fragment portion of a URL.
at line 276
AbstractPaginator
loadMorph(string $relation, array $relations)
Load a set of relationships onto the mixed relationship collection.
at line 290
AbstractPaginator
loadMorphCount(string $relation, array $relations)
Load a set of relationship counts onto the mixed relationship collection.
at line 303
array
items()
Get the slice of items being paginated.
at line 311
int|null
firstItem()
Get the number of the first item in the slice.
at line 319
int|null
lastItem()
Get the number of the last item in the slice.
at line 334
AbstractPaginator
through(callable $callback)
Transform each item in the slice of items using a callback.
at line 344
int
perPage()
Get the number of items shown per page.
at line 352
bool
hasPages()
Determine if there are enough items to split into multiple pages.
at line 360
bool
onFirstPage()
Determine if the paginator is on the first page.
at line 368
bool
onLastPage()
Determine if the paginator is on the last page.
at line 376
int
currentPage()
Get the current page.
at line 384
string
getPageName()
Get the query string variable used to store the page.
at line 394
AbstractPaginator
setPageName(string $name)
Set the query string variable used to store the page.
at line 406
AbstractPaginator
withPath(string $path)
Set the base path to assign to all URLs.
at line 416
AbstractPaginator
setPath(string $path)
Set the base path to assign to all URLs.
at line 428
AbstractPaginator
onEachSide(int $count)
Set the number of links to display on each side of current page link.
at line 438
string|null
path()
Get the base path for paginator generated URLs.
at line 446
static string
resolveCurrentPath(string $default = '/')
Resolve the current request path or return the default value.
at line 461
static void
currentPathResolver(Closure $resolver)
Set the current request path resolver callback.
Boot-only. The resolver persists in a static property for the worker lifetime and runs on every subsequent paginator's path lookup.
at line 469
static int
resolveCurrentPage(string $pageName = 'page', int $default = 1)
Resolve the current page or return the default value.
at line 484
static void
currentPageResolver(Closure $resolver)
Set the current page resolver callback.
Boot-only. The resolver persists in a static property for the worker lifetime and runs on every subsequent paginator's page lookup.
at line 492
static string|array|null
resolveQueryString(string|array|null $default = null)
Resolve the query string or return the default value.
at line 507
static void
queryStringResolver(Closure $resolver)
Set with query string resolver callback.
Boot-only. The resolver persists in a static property for the worker lifetime and runs on every subsequent paginator's query-string lookup.
at line 515
static mixed
viewFactory()
Get an instance of the view factory from the resolver.
at line 526
static void
viewFactoryResolver(Closure $resolver)
Set the view factory resolver callback.
Boot-only. The resolver persists in a static property for the worker lifetime and runs on every subsequent paginator render.
at line 537
static void
defaultView(string $view)
Set the default pagination view.
Boot-only. The view name persists in a static property for the worker lifetime and applies to every subsequent paginator render.
at line 548
static void
defaultSimpleView(string $view)
Set the default "simple" pagination view.
Boot-only. The view name persists in a static property for the worker lifetime and applies to every subsequent simple-paginator render.
at line 559
static void
useTailwind()
Indicate that Tailwind styling should be used for generated links.
Boot-only. Sets the default view names in static properties for the worker lifetime; applies to every subsequent paginator render.
at line 568
static void
flushState()
Flush all static state.
at line 583
Traversable
getIterator()
Get an iterator for the items.
at line 591
bool
isEmpty()
Determine if the list of items is empty.
at line 599
bool
isNotEmpty()
Determine if the list of items is not empty.
at line 607
int
count()
Get the number of items for the current page.
at line 617
Collection
getCollection()
Get the paginator's underlying collection.
at line 628
AbstractPaginator
setCollection(Collection $collection)
Set the paginator's underlying collection.
at line 640
array
getOptions()
Get the paginator options.
at line 650
bool
offsetExists(TKey $key)
Determine if the given item exists.
at line 661
mixed
offsetGet(TKey $key)
Get the item at the given offset.
at line 672
void
offsetSet(null|TKey $key, TValue $value)
Set the item at the given offset.
at line 682
void
offsetUnset(TKey $key)
Unset the item at the given key.
at line 690
string
toHtml()
Render the contents of the paginator to HTML.
at line 702
mixed
__call(string $method, array $parameters)
Make dynamic calls into the collection.
at line 710
string
__toString()
Render the contents of the paginator when casting to a string.
at line 727
CanBeEscapedWhenCastToString
escapeWhenCastingToString(bool $escape = true)
Indicate that the paginator's string representation should be escaped when __toString is invoked.