Documentation

Paginator extends AbstractPaginator
in package
implements Arrayable, ArrayAccess, Countable, IteratorAggregate, JsonSerializable, Jsonable, Paginator

Interfaces, Classes and Traits

Arrayable
ArrayAccess
Countable
IteratorAggregate
JsonSerializable
Jsonable
Paginator

Table of Contents

$defaultSimpleView  : string
The default "simple" pagination view.
$defaultView  : string
The default pagination view.
$currentPage  : int
The current page being "viewed".
$currentPageResolver  : Closure
The current page resolver callback.
$currentPathResolver  : Closure
The current path resolver callback.
$fragment  : string|null
The URL fragment to add to all URLs.
$hasMore  : mixed
Determine if there are more items in the data source.
$items  : Collection
All of the items being paginated.
$pageName  : string
The query string variable used to store the page.
$path  : string
The base path to assign to all URLs.
$perPage  : int
The number of items to be shown per page.
$query  : array<string|int, mixed>
The query parameters to add to all URLs.
$viewFactoryResolver  : Closure
The view factory resolver callback.
__call()  : mixed
Make dynamic calls into the collection.
__construct()  : void
Create a new paginator instance.
__toString()  : string
Render the contents of the paginator when casting to string.
appends()  : $this
Add a set of query string values to the paginator.
count()  : int
Get the number of items for the current page.
currentPage()  : int
Get the current page.
currentPageResolver()  : void
Set the current page resolver callback.
currentPathResolver()  : void
Set the current request path resolver callback.
defaultSimpleView()  : void
Set the default "simple" pagination view.
defaultView()  : void
Set the default pagination view.
firstItem()  : int
Get the number of the first item in the slice.
fragment()  : $this|string|null
Get / set the URL fragment to be appended to URLs.
getCollection()  : Collection
Get the paginator's underlying collection.
getIterator()  : ArrayIterator
Get an iterator for the items.
getPageName()  : string
Get the query string variable used to store the page.
getUrlRange()  : array<string|int, mixed>
Create a range of pagination URLs.
hasMorePages()  : bool
Determine if there are more items in the data source.
hasMorePagesWhen()  : $this
Manually indicate that the paginator does have more pages.
hasPages()  : bool
Determine if there are enough items to split into multiple pages.
isEmpty()  : bool
Determine if the list of items is empty or not.
isNotEmpty()  : bool
Determine if the list of items is not empty.
items()  : array<string|int, mixed>
Get the slice of items being paginated.
jsonSerialize()  : array<string|int, mixed>
Convert the object into something JSON serializable.
lastItem()  : int
Get the number of the last item in the slice.
links()  : string
Render the paginator using the given view.
nextPageUrl()  : string|null
Get the URL for the next page.
offsetExists()  : bool
Determine if the given item exists.
offsetGet()  : mixed
Get the item at the given offset.
offsetSet()  : void
Set the item at the given offset.
offsetUnset()  : void
Unset the item at the given key.
onFirstPage()  : bool
Determine if the paginator is on the first page.
perPage()  : int
Get the number of items shown per page.
previousPageUrl()  : string|null
Get the URL for the previous page.
render()  : string
Render the paginator using the given view.
resolveCurrentPage()  : int
Resolve the current page or return the default value.
resolveCurrentPath()  : string
Resolve the current request path or return the default value.
setCollection()  : $this
Set the paginator's underlying collection.
setPageName()  : $this
Set the query string variable used to store the page.
setPath()  : $this
Set the base path to assign to all URLs.
toArray()  : array<string|int, mixed>
Get the instance as an array.
toHtml()  : string
Render the contents of the paginator to HTML.
toJson()  : string
Convert the object to its JSON representation.
url()  : string
Get the URL for a given page number.
viewFactory()  : Factory
Get an instance of the view factory from the resolver.
viewFactoryResolver()  : void
Set the view factory resolver callback.
withPath()  : $this
Set the base path to assign to all URLs.
addQuery()  : $this
Add a query string value to the paginator.
appendArray()  : $this
Add an array of query string values.
buildFragment()  : string
Build the full fragment portion of a URL.
isValidPageNumber()  : bool
Determine if the given value is a valid page number.
setCurrentPage()  : int
Get the current page for the request.
setItems()  : void
Set the items for the paginator.

Properties

$defaultSimpleView

The default "simple" pagination view.

public static string $defaultSimpleView = 'pagination::simple-default'

$defaultView

The default pagination view.

public static string $defaultView = 'pagination::default'

$currentPageResolver

The current page resolver callback.

protected static Closure $currentPageResolver

$currentPathResolver

The current path resolver callback.

protected static Closure $currentPathResolver

$fragment

The URL fragment to add to all URLs.

protected string|null $fragment

$hasMore

Determine if there are more items in the data source.

protected mixed $hasMore

$pageName

The query string variable used to store the page.

protected string $pageName = 'page'

$query

The query parameters to add to all URLs.

protected array<string|int, mixed> $query = []

$viewFactoryResolver

The view factory resolver callback.

protected static Closure $viewFactoryResolver

Methods

__call()

Make dynamic calls into the collection.

public __call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Return values
mixed

__construct()

Create a new paginator instance.

public __construct(mixed $items, int $perPage[, int|null $currentPage = null ][, array<string|int, mixed> $options = [] ]) : void
Parameters
$items : mixed
$perPage : int
$currentPage : int|null = null
$options : array<string|int, mixed> = []

(path, query, fragment, pageName)

Return values
void

__toString()

Render the contents of the paginator when casting to string.

public __toString() : string
Return values
string

appends()

Add a set of query string values to the paginator.

public appends(array<string|int, mixed>|string $key[, string|null $value = null ]) : $this
Parameters
$key : array<string|int, mixed>|string
$value : string|null = null
Return values
$this

count()

Get the number of items for the current page.

public count() : int
Return values
int

currentPage()

Get the current page.

public currentPage() : int
Return values
int

currentPageResolver()

Set the current page resolver callback.

public static currentPageResolver(Closure $resolver) : void
Parameters
$resolver : Closure
Return values
void

currentPathResolver()

Set the current request path resolver callback.

public static currentPathResolver(Closure $resolver) : void
Parameters
$resolver : Closure
Return values
void

defaultSimpleView()

Set the default "simple" pagination view.

public static defaultSimpleView(string $view) : void
Parameters
$view : string
Return values
void

defaultView()

Set the default pagination view.

public static defaultView(string $view) : void
Parameters
$view : string
Return values
void

firstItem()

Get the number of the first item in the slice.

public firstItem() : int
Return values
int

fragment()

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

public fragment([string|null $fragment = null ]) : $this|string|null
Parameters
$fragment : string|null = null
Return values
$this|string|null

getIterator()

Get an iterator for the items.

public getIterator() : ArrayIterator
Return values
ArrayIterator

getPageName()

Get the query string variable used to store the page.

public getPageName() : string
Return values
string

getUrlRange()

Create a range of pagination URLs.

public getUrlRange(int $start, int $end) : array<string|int, mixed>
Parameters
$start : int
$end : int
Return values
array<string|int, mixed>

hasMorePages()

Determine if there are more items in the data source.

public hasMorePages() : bool
Return values
bool

hasMorePagesWhen()

Manually indicate that the paginator does have more pages.

public hasMorePagesWhen([bool $hasMore = true ]) : $this
Parameters
$hasMore : bool = true
Return values
$this

hasPages()

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

public hasPages() : bool
Return values
bool

isEmpty()

Determine if the list of items is empty or not.

public isEmpty() : bool
Return values
bool

isNotEmpty()

Determine if the list of items is not empty.

public isNotEmpty() : bool
Return values
bool

items()

Get the slice of items being paginated.

public items() : array<string|int, mixed>
Return values
array<string|int, mixed>

jsonSerialize()

Convert the object into something JSON serializable.

public jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

lastItem()

Get the number of the last item in the slice.

public lastItem() : int
Return values
int

Render the paginator using the given view.

public links([string|null $view = null ][, array<string|int, mixed> $data = [] ]) : string
Parameters
$view : string|null = null
$data : array<string|int, mixed> = []
Return values
string

nextPageUrl()

Get the URL for the next page.

public nextPageUrl() : string|null
Return values
string|null

offsetExists()

Determine if the given item exists.

public offsetExists(mixed $key) : bool
Parameters
$key : mixed
Return values
bool

offsetGet()

Get the item at the given offset.

public offsetGet(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

offsetSet()

Set the item at the given offset.

public offsetSet(mixed $key, mixed $value) : void
Parameters
$key : mixed
$value : mixed
Return values
void

offsetUnset()

Unset the item at the given key.

public offsetUnset(mixed $key) : void
Parameters
$key : mixed
Return values
void

onFirstPage()

Determine if the paginator is on the first page.

public onFirstPage() : bool
Return values
bool

perPage()

Get the number of items shown per page.

public perPage() : int
Return values
int

previousPageUrl()

Get the URL for the previous page.

public previousPageUrl() : string|null
Return values
string|null

render()

Render the paginator using the given view.

public render([string|null $view = null ][, array<string|int, mixed> $data = [] ]) : string
Parameters
$view : string|null = null
$data : array<string|int, mixed> = []
Return values
string

resolveCurrentPage()

Resolve the current page or return the default value.

public static resolveCurrentPage([string $pageName = 'page' ][, int $default = 1 ]) : int
Parameters
$pageName : string = 'page'
$default : int = 1
Return values
int

resolveCurrentPath()

Resolve the current request path or return the default value.

public static resolveCurrentPath([string $default = '/' ]) : string
Parameters
$default : string = '/'
Return values
string

setPageName()

Set the query string variable used to store the page.

public setPageName(string $name) : $this
Parameters
$name : string
Return values
$this

setPath()

Set the base path to assign to all URLs.

public setPath(string $path) : $this
Parameters
$path : string
Return values
$this

toArray()

Get the instance as an array.

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

toHtml()

Render the contents of the paginator to HTML.

public toHtml() : string
Return values
string

toJson()

Convert the object to its JSON representation.

public toJson(int $options) : string
Parameters
$options : int
Return values
string

url()

Get the URL for a given page number.

public url(int $page) : string
Parameters
$page : int
Return values
string

viewFactoryResolver()

Set the view factory resolver callback.

public static viewFactoryResolver(Closure $resolver) : void
Parameters
$resolver : Closure
Return values
void

withPath()

Set the base path to assign to all URLs.

public withPath(string $path) : $this
Parameters
$path : string
Return values
$this

addQuery()

Add a query string value to the paginator.

protected addQuery(string $key, string $value) : $this
Parameters
$key : string
$value : string
Return values
$this

appendArray()

Add an array of query string values.

protected appendArray(array<string|int, mixed> $keys) : $this
Parameters
$keys : array<string|int, mixed>
Return values
$this

buildFragment()

Build the full fragment portion of a URL.

protected buildFragment() : string
Return values
string

isValidPageNumber()

Determine if the given value is a valid page number.

protected isValidPageNumber(int $page) : bool
Parameters
$page : int
Return values
bool

setCurrentPage()

Get the current page for the request.

protected setCurrentPage(int $currentPage) : int
Parameters
$currentPage : int
Return values
int

setItems()

Set the items for the paginator.

protected setItems(mixed $items) : void
Parameters
$items : mixed
Return values
void

Search results