abstract class AbstractCursorPaginator implements Htmlable mixin Collection (View source)

Traits

Properties

protected Collection $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 $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 $parameters

The paginator parameters for the cursor.

protected array $options

The paginator options.

static protected Closure $currentCursorResolver

The current cursor resolver callback.

Methods

mixed
forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

mixed
forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

static void
throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

mixed
tap(callable|null $callback = null)

Call the given Closure with this instance then return the instance.

from  Tappable
string
url(Cursor|null $cursor)

Get the URL for a given cursor.

string|null
previousPageUrl()

Get the URL for the previous page.

string|null
nextPageUrl()

The URL for the next page, or null.

Cursor|null
previousCursor()

Get the "cursor" that points to the previous set of items.

Cursor|null
nextCursor()

Get the "cursor" that points to the next set of items.

getCursorForItem(ArrayAccess|stdClass $item, bool $isNext = true)

Get a cursor instance for the given item.

array
getParametersForItem(ArrayAccess|stdClass $item)

Get the cursor parameters for a given object.

string|null
getPivotParameterForItem(ArrayAccess|stdClass $item, string $parameterName)

Get the cursor parameter value from a pivot model if applicable.

mixed
ensureParameterIsPrimitive(mixed $parameter)

Ensure the parameter is a primitive type.

$this|string|null
fragment(string|null $fragment = null)

Get / set the URL fragment to be appended to URLs.

$this
appends(array|string|null $key, string|null $value = null)

Add a set of query string values to the paginator.

$this
appendArray(array $keys)

Add an array of query string values.

$this
withQueryString()

Add all current query string values to the paginator.

$this
addQuery(string $key, string $value)

Add a query string value to the paginator.

string
buildFragment()

Build the full fragment portion of a URL.

$this
loadMorph(string $relation, array $relations)

Load a set of relationships onto the mixed relationship collection.

$this
loadMorphCount(string $relation, array $relations)

Load a set of relationship counts onto the mixed relationship collection.

array
items()

Get the slice of items being paginated.

$this
through(callable $callback)

Transform each item in the slice of items using a callback.

int
perPage()

Get the number of items shown per page.

Cursor|null
cursor()

Get the current cursor being paginated.

string
getCursorName()

Get the query string variable used to store the cursor.

$this
setCursorName(string $name)

Set the query string variable used to store the cursor.

$this
withPath(string $path)

Set the base path to assign to all URLs.

$this
setPath(string $path)

Set the base path to assign to all URLs.

string|null
path()

Get the base path for paginator generated URLs.

static Cursor|null
resolveCurrentCursor(string $cursorName = 'cursor', $default = null)

Resolve the current cursor or return the default value.

static void
currentCursorResolver(Closure $resolver)

Set the current cursor resolver callback.

static Factory
viewFactory()

Get an instance of the view factory from the resolver.

getIterator()

Get an iterator for the items.

bool
isEmpty()

Determine if the list of items is empty.

bool
isNotEmpty()

Determine if the list of items is not empty.

int
count()

Get the number of items for the current page.

getCollection()

Get the paginator's underlying collection.

$this
setCollection(Collection $collection)

Set the paginator's underlying collection.

array
getOptions()

Get the paginator options.

bool
offsetExists(mixed $key)

Determine if the given item exists.

mixed
offsetGet(mixed $key)

Get the item at the given offset.

void
offsetSet(mixed $key, mixed $value)

Set the item at the given offset.

void
offsetUnset(mixed $key)

Unset the item at the given key.

string
toHtml()

Render the contents of the paginator to HTML.

mixed
__call(string $method, array $parameters)

Make dynamic calls into the collection.

string
__toString()

Render the contents of the paginator when casting to a string.

Details

protected mixed forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

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.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

static protected void throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

Parameters

string $method

Return Value

void

Exceptions

BadMethodCallException

mixed tap(callable|null $callback = null)

Call the given Closure with this instance then return the instance.

Parameters

callable|null $callback

Return Value

mixed

string url(Cursor|null $cursor)

Get the URL for a given cursor.

Parameters

Cursor|null $cursor

Return Value

string

string|null previousPageUrl()

Get the URL for the previous page.

Return Value

string|null

string|null nextPageUrl()

The URL for the next page, or null.

Return Value

string|null

Cursor|null previousCursor()

Get the "cursor" that points to the previous set of items.

Return Value

Cursor|null

Cursor|null nextCursor()

Get the "cursor" that points to the next set of items.

Return Value

Cursor|null

Cursor getCursorForItem(ArrayAccess|stdClass $item, bool $isNext = true)

Get a cursor instance for the given item.

Parameters

ArrayAccess|stdClass $item
bool $isNext

Return Value

Cursor

array getParametersForItem(ArrayAccess|stdClass $item)

Get the cursor parameters for a given object.

Parameters

ArrayAccess|stdClass $item

Return Value

array

Exceptions

Exception

protected string|null getPivotParameterForItem(ArrayAccess|stdClass $item, string $parameterName)

Get the cursor parameter value from a pivot model if applicable.

Parameters

ArrayAccess|stdClass $item
string $parameterName

Return Value

string|null

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.

Parameters

mixed $parameter

Return Value

mixed

$this|string|null fragment(string|null $fragment = null)

Get / set the URL fragment to be appended to URLs.

Parameters

string|null $fragment

Return Value

$this|string|null

$this appends(array|string|null $key, string|null $value = null)

Add a set of query string values to the paginator.

Parameters

array|string|null $key
string|null $value

Return Value

$this

protected $this appendArray(array $keys)

Add an array of query string values.

Parameters

array $keys

Return Value

$this

$this withQueryString()

Add all current query string values to the paginator.

Return Value

$this

protected $this addQuery(string $key, string $value)

Add a query string value to the paginator.

Parameters

string $key
string $value

Return Value

$this

protected string buildFragment()

Build the full fragment portion of a URL.

Return Value

string

$this loadMorph(string $relation, array $relations)

Load a set of relationships onto the mixed relationship collection.

Parameters

string $relation
array $relations

Return Value

$this

$this loadMorphCount(string $relation, array $relations)

Load a set of relationship counts onto the mixed relationship collection.

Parameters

string $relation
array $relations

Return Value

$this

array items()

Get the slice of items being paginated.

Return Value

array

$this through(callable $callback)

Transform each item in the slice of items using a callback.

Parameters

callable $callback

Return Value

$this

int perPage()

Get the number of items shown per page.

Return Value

int

Cursor|null cursor()

Get the current cursor being paginated.

Return Value

Cursor|null

string getCursorName()

Get the query string variable used to store the cursor.

Return Value

string

$this setCursorName(string $name)

Set the query string variable used to store the cursor.

Parameters

string $name

Return Value

$this

$this withPath(string $path)

Set the base path to assign to all URLs.

Parameters

string $path

Return Value

$this

$this setPath(string $path)

Set the base path to assign to all URLs.

Parameters

string $path

Return Value

$this

string|null path()

Get the base path for paginator generated URLs.

Return Value

string|null

static Cursor|null resolveCurrentCursor(string $cursorName = 'cursor', $default = null)

Resolve the current cursor or return the default value.

Parameters

string $cursorName
$default

Return Value

Cursor|null

static void currentCursorResolver(Closure $resolver)

Set the current cursor resolver callback.

Parameters

Closure $resolver

Return Value

void

static Factory viewFactory()

Get an instance of the view factory from the resolver.

Return Value

Factory

ArrayIterator getIterator()

Get an iterator for the items.

Return Value

ArrayIterator

bool isEmpty()

Determine if the list of items is empty.

Return Value

bool

bool isNotEmpty()

Determine if the list of items is not empty.

Return Value

bool

int count()

Get the number of items for the current page.

Return Value

int

Collection getCollection()

Get the paginator's underlying collection.

Return Value

Collection

$this setCollection(Collection $collection)

Set the paginator's underlying collection.

Parameters

Collection $collection

Return Value

$this

array getOptions()

Get the paginator options.

Return Value

array

bool offsetExists(mixed $key)

Determine if the given item exists.

Parameters

mixed $key

Return Value

bool

mixed offsetGet(mixed $key)

Get the item at the given offset.

Parameters

mixed $key

Return Value

mixed

void offsetSet(mixed $key, mixed $value)

Set the item at the given offset.

Parameters

mixed $key
mixed $value

Return Value

void

void offsetUnset(mixed $key)

Unset the item at the given key.

Parameters

mixed $key

Return Value

void

string toHtml()

Render the contents of the paginator to HTML.

Return Value

string

mixed __call(string $method, array $parameters)

Make dynamic calls into the collection.

Parameters

string $method
array $parameters

Return Value

mixed

string __toString()

Render the contents of the paginator when casting to a string.

Return Value

string