AbstractCursorPaginator
abstract class AbstractCursorPaginator implements Htmlable, Stringable mixin TKey,
Traits
Properties
| protected bool | $hasMore | Indicates whether there are more items in the data source. |
|
| protected TValue> | $items | All of the items being paginated. |
|
| protected int | $perPage | The number of items to be shown per page. |
|
| 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 | $cursorName | The cursor string variable used to store the page. |
|
| protected Cursor|null | $cursor | The current cursor. |
|
| protected array<int, string> | $parameters | The paginator parameters for the cursor. |
|
| protected array<string, mixed> | $options | The paginator options. |
|
| static protected Closure|null | $currentCursorResolver | The current cursor resolver callback. |
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.
Get the URL for the previous page.
The URL for the next page, or null.
Get the "cursor" that points to the previous set of items.
Get the "cursor" that points to the next set of items.
Get a cursor instance for the given item.
Get the cursor parameters for a given object.
Get the cursor parameter value from a pivot model if applicable.
Ensure the parameter is a primitive type.
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.
Transform each item in the slice of items using a callback.
Get the number of items shown per page.
Get the query string variable used to store the cursor.
Set the query string variable used to store the cursor.
Set the base path to assign to all URLs.
Set the base path to assign to all URLs.
Get the base path for paginator generated URLs.
Resolve the current cursor or return the default value.
Get an instance of the view factory from the resolver.
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.
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 42
abstract Htmlable
render(string|null $view = null, array $data = [])
Render the paginator using the given view.
at line 110
string
url(Cursor|null $cursor)
Get the URL for a given cursor.
at line 130
string|null
previousPageUrl()
Get the URL for the previous page.
at line 142
string|null
nextPageUrl()
The URL for the next page, or null.
at line 154
Cursor|null
previousCursor()
Get the "cursor" that points to the previous set of items.
at line 171
Cursor|null
nextCursor()
Get the "cursor" that points to the next set of items.
at line 188
Cursor
getCursorForItem(array|object $item, bool $isNext = true)
Get a cursor instance for the given item.
at line 200
array
getParametersForItem(array|object $item)
Get the cursor parameters for a given object.
at line 232
protected string|null
getPivotParameterForItem(Model $item, string $parameterName)
Get the cursor parameter value from a pivot model if applicable.
at line 252
protected mixed
ensureParameterIsPrimitive(mixed $parameter)
Ensure the parameter is a primitive type.
This can resolve issues that arise the developer uses a value object for an attribute.
at line 264
AbstractCursorPaginator|string|null
fragment(string|null $fragment = null)
Get / set the URL fragment to be appended to URLs.
at line 280
AbstractCursorPaginator
appends(array|string|null $key, string|null $value = null)
Add a set of query string values to the paginator.
at line 299
protected AbstractCursorPaginator
appendArray(array $keys)
Add an array of query string values.
at line 313
AbstractCursorPaginator
withQueryString()
Add all current query string values to the paginator.
at line 327
protected AbstractCursorPaginator
addQuery(string $key, mixed $value)
Add a query string value to the paginator.
at line 339
protected string
buildFragment()
Build the full fragment portion of a URL.
at line 350
AbstractCursorPaginator
loadMorph(string $relation, array $relations)
Load a set of relationships onto the mixed relationship collection.
at line 364
AbstractCursorPaginator
loadMorphCount(string $relation, array $relations)
Load a set of relationship counts onto the mixed relationship collection.
at line 377
array
items()
Get the slice of items being paginated.
at line 392
AbstractCursorPaginator
through(callable $callback)
Transform each item in the slice of items using a callback.
at line 402
int
perPage()
Get the number of items shown per page.
at line 410
Cursor|null
cursor()
Get the current cursor being paginated.
at line 418
string
getCursorName()
Get the query string variable used to store the cursor.
at line 428
AbstractCursorPaginator
setCursorName(string $name)
Set the query string variable used to store the cursor.
at line 440
AbstractCursorPaginator
withPath(string $path)
Set the base path to assign to all URLs.
at line 450
AbstractCursorPaginator
setPath(string $path)
Set the base path to assign to all URLs.
at line 460
string|null
path()
Get the base path for paginator generated URLs.
at line 468
static Cursor|null
resolveCurrentCursor(string $cursorName = 'cursor', Cursor|null $default = null)
Resolve the current cursor or return the default value.
at line 483
static void
currentCursorResolver(Closure $resolver)
Set the current cursor resolver callback.
Boot-only. The resolver persists in a static property for the worker lifetime and runs on every subsequent cursor-paginator's cursor lookup.
at line 491
static mixed
viewFactory()
Get an instance of the view factory from the resolver.
at line 499
static void
flushState()
Flush all static state.
at line 509
Traversable
getIterator()
Get an iterator for the items.
at line 517
bool
isEmpty()
Determine if the list of items is empty.
at line 525
bool
isNotEmpty()
Determine if the list of items is not empty.
at line 533
int
count()
Get the number of items for the current page.
at line 543
Collection
getCollection()
Get the paginator's underlying collection.
at line 559
AbstractCursorPaginator
setCollection(Collection $collection)
Set the paginator's underlying collection.
at line 572
array
getOptions()
Get the paginator options.
at line 582
bool
offsetExists(TKey $key)
Determine if the given item exists.
at line 593
mixed
offsetGet(TKey $key)
Get the item at the given offset.
at line 604
void
offsetSet(null|TKey $key, TValue $value)
Set the item at the given offset.
at line 614
void
offsetUnset(TKey $key)
Unset the item at the given key.
at line 622
string
toHtml()
Render the contents of the paginator to HTML.
at line 634
mixed
__call(string $method, array $parameters)
Make dynamic calls into the collection.
at line 642
string
__toString()
Render the contents of the paginator when casting to a string.