AbstractPaginator

class AbstractPaginator (View source)

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.
static protected Closure $currentPathResolver The current page resolver callback.
static protected Closure $currentPageResolver The current page resolver callback.
static protected Closure $presenterResolver The default presenter resolver.

Methods

bool isValidPageNumber(int $page)

Determine if the given value is a valid page number.

string getUrlRange(int $start, int $end)

Create a range of pagination URLs.

string url(int $page)

Get a URL for a given page number.

string|null previousPageUrl()

Get the URL for the previous page.

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

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

$this appends(array|string $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 addQuery(string $key, string $value)

Add a query string value to the paginator.

string buildFragment()

Build the full fragment portion of a URL.

array items()

Get the slice of items being paginated.

int firstItem()

Get the number of the first item in the slice.

int lastItem()

Get the number of the last item in the slice.

int perPage()

Get the number of items shown per page.

int currentPage()

Get the current page.

bool hasPages()

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

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 void presenter(Closure $resolver)

Set the default Presenter resolver.

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 setPath(string $path)

Set the base path to assign to all URLs.

ArrayIterator getIterator()

Get an iterator for the items.

bool isEmpty()

Determine if the list of items is empty or not.

int count()

Get the number of items for the current page.

Collection getCollection()

Get the paginator's underlying collection.

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.

mixed __call(string $method, array $parameters)

Make dynamic calls into the collection.

string __toString()

Render the contents of the paginator when casting to string.

Details

protected bool isValidPageNumber(int $page)

Determine if the given value is a valid page number.

Parameters

int $page

Return Value

bool

string getUrlRange(int $start, int $end)

Create a range of pagination URLs.

Parameters

int $start
int $end

Return Value

string

string url(int $page)

Get a URL for a given page number.

Parameters

int $page

Return Value

string

string|null previousPageUrl()

Get the URL for the previous page.

Return Value

string|null

$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 $key, string|null $value = null)

Add a set of query string values to the paginator.

Parameters

array|string $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 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

array items()

Get the slice of items being paginated.

Return Value

array

int firstItem()

Get the number of the first item in the slice.

Return Value

int

int lastItem()

Get the number of the last item in the slice.

Return Value

int

int perPage()

Get the number of items shown per page.

Return Value

int

int currentPage()

Get the current page.

Return Value

int

bool hasPages()

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

Return Value

bool

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 void presenter(Closure $resolver)

Set the default Presenter resolver.

Parameters

Closure $resolver

Return Value

void

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 setPath(string $path)

Set the base path to assign to all URLs.

Parameters

string $path

Return Value

$this

ArrayIterator getIterator()

Get an iterator for the items.

Return Value

ArrayIterator

bool isEmpty()

Determine if the list of items is empty or not.

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

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

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

Return Value

string

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.1/Illuminate/Pagination/AbstractPaginator.html