abstract class AbstractPaginator 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 int $currentPage

The current page being "viewed".

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 $pageName

The query string variable used to store the page.

int $onEachSide

The number of links to display on each side of current page link.

protected array $options

The paginator options.

static protected Closure $currentPathResolver

The current path resolver callback.

static protected Closure $currentPageResolver

The current page resolver callback.

static protected Closure $queryStringResolver

The query string resolver callback.

static protected Closure $viewFactoryResolver

The view factory resolver callback.

static string $defaultView

The default pagination view.

static string $defaultSimpleView

The default "simple" pagination view.

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.

tap(callable|null $callback = null)

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

from  Tappable
bool
isValidPageNumber(int $page)

Determine if the given value is a valid page number.

string|null
previousPageUrl()

Get the URL for the previous page.

array
getUrlRange(int $start, int $end)

Create a range of pagination URLs.

string
url(int $page)

Get the URL for a given page number.

$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.

int|null
firstItem()

Get the number of the first item in the slice.

int|null
lastItem()

Get the number of the last item in the slice.

$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.

bool
hasPages()

Determine if there are enough items to split into multiple pages.

bool
onFirstPage()

Determine if the paginator is on the first page.

bool
onLastPage()

Determine if the paginator is on the last page.

int
currentPage()

Get the current page.

string
getPageName()

Get the query string variable used to store the page.

$this
setPageName(string $name)

Set the query string variable used to store the page.

$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.

$this
onEachSide(int $count)

Set the number of links to display on each side of current page link.

string|null
path()

Get the base path for paginator generated URLs.

static string
resolveCurrentPath(string $default = '/')

Resolve the current request path or return the default value.

static void
currentPathResolver(Closure $resolver)

Set the current request path resolver callback.

static int
resolveCurrentPage(string $pageName = 'page', int $default = 1)

Resolve the current page or return the default value.

static void
currentPageResolver(Closure $resolver)

Set the current page resolver callback.

static string
resolveQueryString(string|array|null $default = null)

Resolve the query string or return the default value.

static void
queryStringResolver(Closure $resolver)

Set with query string resolver callback.

static Factory
viewFactory()

Get an instance of the view factory from the resolver.

static void
viewFactoryResolver(Closure $resolver)

Set the view factory resolver callback.

static void
defaultView(string $view)

Set the default pagination view.

static void
defaultSimpleView(string $view)

Set the default "simple" pagination view.

static void
useTailwind()

Indicate that Tailwind styling should be used for generated links.

static void
useBootstrap()

Indicate that Bootstrap 4 styling should be used for generated links.

static void
useBootstrapThree()

Indicate that Bootstrap 3 styling should be used for generated links.

static void
useBootstrapFour()

Indicate that Bootstrap 4 styling should be used for generated links.

static void
useBootstrapFive()

Indicate that Bootstrap 5 styling should be used for generated links.

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

$this|HigherOrderTapProxy tap(callable|null $callback = null)

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

Parameters

callable|null $callback

Return Value

$this|HigherOrderTapProxy

protected bool isValidPageNumber(int $page)

Determine if the given value is a valid page number.

Parameters

int $page

Return Value

bool

string|null previousPageUrl()

Get the URL for the previous page.

Return Value

string|null

array getUrlRange(int $start, int $end)

Create a range of pagination URLs.

Parameters

int $start
int $end

Return Value

array

string url(int $page)

Get the URL for a given page number.

Parameters

int $page

Return Value

string

$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

int|null firstItem()

Get the number of the first item in the slice.

Return Value

int|null

int|null lastItem()

Get the number of the last item in the slice.

Return Value

int|null

$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

bool hasPages()

Determine if there are enough items to split into multiple pages.

Return Value

bool

bool onFirstPage()

Determine if the paginator is on the first page.

Return Value

bool

bool onLastPage()

Determine if the paginator is on the last page.

Return Value

bool

int currentPage()

Get the current page.

Return Value

int

string getPageName()

Get the query string variable used to store the page.

Return Value

string

$this setPageName(string $name)

Set the query string variable used to store the page.

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

$this onEachSide(int $count)

Set the number of links to display on each side of current page link.

Parameters

int $count

Return Value

$this

string|null path()

Get the base path for paginator generated URLs.

Return Value

string|null

static string resolveCurrentPath(string $default = '/')

Resolve the current request path or return the default value.

Parameters

string $default

Return Value

string

static void currentPathResolver(Closure $resolver)

Set the current request path resolver callback.

Parameters

Closure $resolver

Return Value

void

static int resolveCurrentPage(string $pageName = 'page', int $default = 1)

Resolve the current page or return the default value.

Parameters

string $pageName
int $default

Return Value

int

static void currentPageResolver(Closure $resolver)

Set the current page resolver callback.

Parameters

Closure $resolver

Return Value

void

static string resolveQueryString(string|array|null $default = null)

Resolve the query string or return the default value.

Parameters

string|array|null $default

Return Value

string

static void queryStringResolver(Closure $resolver)

Set with query string resolver callback.

Parameters

Closure $resolver

Return Value

void

static Factory viewFactory()

Get an instance of the view factory from the resolver.

Return Value

Factory

static void viewFactoryResolver(Closure $resolver)

Set the view factory resolver callback.

Parameters

Closure $resolver

Return Value

void

static void defaultView(string $view)

Set the default pagination view.

Parameters

string $view

Return Value

void

static void defaultSimpleView(string $view)

Set the default "simple" pagination view.

Parameters

string $view

Return Value

void

static void useTailwind()

Indicate that Tailwind styling should be used for generated links.

Return Value

void

static void useBootstrap()

Indicate that Bootstrap 4 styling should be used for generated links.

Return Value

void

static void useBootstrapThree()

Indicate that Bootstrap 3 styling should be used for generated links.

Return Value

void

static void useBootstrapFour()

Indicate that Bootstrap 4 styling should be used for generated links.

Return Value

void

static void useBootstrapFive()

Indicate that Bootstrap 5 styling should be used for generated links.

Return Value

void

Traversable getIterator()

Get an iterator for the items.

Return Value

Traversable

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