CursorPaginator
class CursorPaginator extends AbstractCursorPaginator implements Arrayable, ArrayAccess, Countable, IteratorAggregate, Jsonable, JsonSerializable, CursorPaginator
Traits
Properties
| protected bool | $hasMore | Indicates whether there are more items in the data source. |
from AbstractCursorPaginator |
| protected TValue> | $items | All of the items being paginated. |
from AbstractCursorPaginator |
| protected int | $perPage | The number of items to be shown per page. |
from AbstractCursorPaginator |
| protected string | $path | The base path to assign to all URLs. |
from AbstractCursorPaginator |
| protected array<array-key, mixed> | $query | The query parameters to add to all URLs. |
from AbstractCursorPaginator |
| protected string|null | $fragment | The URL fragment to add to all URLs. |
from AbstractCursorPaginator |
| protected string | $cursorName | The cursor string variable used to store the page. |
from AbstractCursorPaginator |
| protected Cursor|null | $cursor | The current cursor. |
from AbstractCursorPaginator |
| protected array<int, string> | $parameters | The paginator parameters for the cursor. |
from AbstractCursorPaginator |
| protected array<string, mixed> | $options | The paginator options. |
from AbstractCursorPaginator |
| static protected Closure|null | $currentCursorResolver | The current cursor resolver callback. |
from AbstractCursorPaginator |
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 "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.
Load a set of relationships onto the mixed relationship collection.
Load a set of relationship counts onto the mixed relationship collection.
Transform each item in the slice of items using a callback.
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.
Resolve the current cursor or return the default value.
Get an instance of the view factory from the resolver.
Set the item at the given offset.
Make dynamic calls into the collection.
Render the contents of the paginator when casting to a string.
Create a new paginator instance.
Set the items for the paginator.
Render the paginator using the given view.
Determine if there are more items in the data source.
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 instance as an array.
Convert the object into something JSON serializable.
Convert the object to its JSON representation.
Convert the object to pretty print formatted JSON.
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 92
Htmlable
render(string|null $view = null, array $data = [])
Render the paginator using the given view.
in
AbstractCursorPaginator at line 115
string
url(Cursor|null $cursor)
Get the URL for a given cursor.
in
AbstractCursorPaginator at line 135
string|null
previousPageUrl()
Get the URL for the previous page.
in
AbstractCursorPaginator at line 147
string|null
nextPageUrl()
The URL for the next page, or null.
in
AbstractCursorPaginator at line 159
Cursor|null
previousCursor()
Get the "cursor" that points to the previous set of items.
in
AbstractCursorPaginator at line 176
Cursor|null
nextCursor()
Get the "cursor" that points to the next set of items.
in
AbstractCursorPaginator at line 193
Cursor
getCursorForItem(array|object $item, bool $isNext = true)
Get a cursor instance for the given item.
in
AbstractCursorPaginator at line 205
array
getParametersForItem(array|object $item)
Get the cursor parameters for a given object.
in
AbstractCursorPaginator at line 244
protected mixed
getPivotParameterForItem(Model $item, string $parameterName)
Get the cursor parameter value from a pivot model if applicable.
in
AbstractCursorPaginator at line 270
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.
in
AbstractCursorPaginator at line 282
AbstractCursorPaginator|string|null
fragment(string|null $fragment = null)
Get / set the URL fragment to be appended to URLs.
in
AbstractCursorPaginator at line 298
AbstractCursorPaginator
appends(array|int|string|null $key, array|bool|float|int|string|null $value = null)
Add a set of query string values to the paginator.
in
AbstractCursorPaginator at line 319
protected AbstractCursorPaginator
appendArray(array $keys)
Add an array of query string values.
in
AbstractCursorPaginator at line 333
AbstractCursorPaginator
withQueryString()
Add all current query string values to the paginator.
in
AbstractCursorPaginator at line 347
protected AbstractCursorPaginator
addQuery(int|string $key, mixed $value)
Add a query string value to the paginator.
in
AbstractCursorPaginator at line 359
protected string
buildFragment()
Build the full fragment portion of a URL.
in
AbstractCursorPaginator at line 373
AbstractCursorPaginator
loadMorph(string $relation, array $relations)
Load a set of relationships onto the mixed relationship collection.
in
AbstractCursorPaginator at line 390
AbstractCursorPaginator
loadMorphCount(string $relation, array $relations)
Load a set of relationship counts onto the mixed relationship collection.
in
AbstractCursorPaginator at line 403
array
items()
Get the slice of items being paginated.
in
AbstractCursorPaginator at line 418
AbstractCursorPaginator
through(callable $callback)
Transform each item in the slice of items using a callback.
in
AbstractCursorPaginator at line 428
int
perPage()
Get the number of items shown per page.
in
AbstractCursorPaginator at line 436
Cursor|null
cursor()
Get the current cursor being paginated.
in
AbstractCursorPaginator at line 444
string
getCursorName()
Get the query string variable used to store the cursor.
in
AbstractCursorPaginator at line 454
AbstractCursorPaginator
setCursorName(string $name)
Set the query string variable used to store the cursor.
in
AbstractCursorPaginator at line 466
AbstractCursorPaginator
withPath(string $path)
Set the base path to assign to all URLs.
in
AbstractCursorPaginator at line 476
AbstractCursorPaginator
setPath(string $path)
Set the base path to assign to all URLs.
in
AbstractCursorPaginator at line 486
string|null
path()
Get the base path for paginator generated URLs.
in
AbstractCursorPaginator at line 494
static Cursor|null
resolveCurrentCursor(string $cursorName = 'cursor', Cursor|null $default = null)
Resolve the current cursor or return the default value.
in
AbstractCursorPaginator at line 509
static void
currentCursorResolver(Closure $resolver)
Set the current cursor resolver callback.
The resolver persists in a static property for the worker lifetime and runs on every subsequent cursor-paginator's cursor lookup.
in
AbstractCursorPaginator at line 518
static Factory
viewFactory()
Get an instance of the view factory from the resolver.
in
AbstractCursorPaginator at line 526
static void
flushState()
Flush all static state.
in
AbstractCursorPaginator at line 536
Traversable
getIterator()
Get an iterator for the items.
in
AbstractCursorPaginator at line 544
bool
isEmpty()
Determine if the list of items is empty.
in
AbstractCursorPaginator at line 552
bool
isNotEmpty()
Determine if the list of items is not empty.
in
AbstractCursorPaginator at line 560
int
count()
Get the number of items for the current page.
in
AbstractCursorPaginator at line 570
Collection
getCollection()
Get the paginator's underlying collection.
in
AbstractCursorPaginator at line 587
AbstractCursorPaginator
setCollection(Collection $collection)
Set the paginator's underlying collection.
in
AbstractCursorPaginator at line 599
array
getOptions()
Get the paginator options.
in
AbstractCursorPaginator at line 609
bool
offsetExists(TKey $offset)
Determine if the given item exists.
in
AbstractCursorPaginator at line 620
mixed
offsetGet(TKey $offset)
Get the item at the given offset.
in
AbstractCursorPaginator at line 631
void
offsetSet(null|TKey $offset, TValue $value)
Set the item at the given offset.
in
AbstractCursorPaginator at line 641
void
offsetUnset(TKey $offset)
Unset the item at the given key.
in
AbstractCursorPaginator at line 649
string
toHtml()
Render the contents of the paginator to HTML.
in
AbstractCursorPaginator at line 661
mixed
__call(string $method, array $parameters)
Make dynamic calls into the collection.
in
AbstractCursorPaginator at line 669
string
__toString()
Render the contents of the paginator when casting to a string.
at line 42
__construct(mixed $items, int $perPage, Cursor|null $cursor = null, array $options = [])
Create a new paginator instance.
The items are renumbered, so their keys do not decide TKey.
at line 62
protected void
setItems(mixed $items)
Set the items for the paginator.
at line 82
Htmlable
links(string|null $view = null, array $data = [])
Render the paginator using the given view.
at line 104
bool
hasMorePages()
Determine if there are more items in the data source.
at line 114
bool
hasPages()
Determine if there are enough items to split into multiple pages.
at line 122
bool
onFirstPage()
Determine if the paginator is on the first page.
at line 130
bool
onLastPage()
Determine if the paginator is on the last page.
at line 140
array
toArray()
Get the instance as an array.
at line 158
array
jsonSerialize()
Convert the object into something JSON serializable.
at line 168
string
toJson(int $options = 0)
Convert the object to its JSON representation.
at line 178
string
toPrettyJson(int $options = 0)
Convert the object to pretty print formatted JSON.