File
paginator.php
Package
Default
Class hierarchy
LaravelPaginator

Tags

None found

Properties

$results

$results : array

The results for the current page.

Type

array

Tags

None found

$page

$page : integer

The current page.

Type

integer

Tags

None found

$last

$last : integer

The last page available for the result set.

Type

integer

Tags

None found

$total

$total : integer

The total number of results.

Type

integer

Tags

None found

$per_page

$per_page : integer

The number of items per page.

Type

integer

Tags

None found

$appends

$appends : array

The values that should be appended to the end of the link query strings.

Type

array

Tags

None found

$appendage

$appendage : string

The compiled appendage that will be appended to the links.

This consists of a sprintf format with a page place-holder and query string.

Type

string

Tags

None found

$language

$language : string

The language that should be used when creating the pagination links.

Type

string

Tags

None found

$dots

$dots : string

The "dots" element used in the pagination slider.

Type

string

Tags

None found

Methods

make()

make(array  $results, integer  $total, integer  $per_page) : \Laravel\Paginator

Create a new Paginator instance.

Parameters

array $results
integer $total
integer $per_page

Returns

LaravelPaginator

static

Tags

None found

page()

page(integer  $total, integer  $per_page) : integer

Get the current page from the request query string.

Parameters

integer $total
integer $per_page

Returns

integer

static

Tags

None found

links()

links(integer  $adjacent = 3) : string

Create the HTML pagination links.

Typically, an intelligent, "sliding" window of links will be rendered based on the total number of pages, the current page, and the number of adjacent pages that should rendered. This creates a beautiful paginator similar to that of Google's.

Example: 1 2 ... 23 24 25 [26] 27 28 29 ... 51 52

If you wish to render only certain elements of the pagination control, explore some of the other public methods available on the instance.

// Render the pagination links echo $paginator->links();

// Render the pagination links using a given window size
echo $paginator->links(5);

Parameters

integer $adjacent

Returns

string

Tags

None found

slider()

slider(integer  $adjacent = 3) : string

Build sliding list of HTML numeric page links.

This method is very similar to the "links" method, only it does not render the "first" and "last" pagination links, but only the pages.

// Render the pagination slider echo $paginator->slider();

// Render the pagination slider using a given window size
echo $paginator->slider(5);

Parameters

integer $adjacent

Returns

string

Tags

None found

previous()

previous(string  $text = null) : string

Generate the "previous" HTML link.

// Create the "previous" pagination element echo $paginator->previous();

// Create the "previous" pagination element with custom text
echo $paginator->previous('Go Back');

Parameters

string $text

Returns

string

Tags

None found

next()

next(string  $text = null) : string

Generate the "next" HTML link.

// Create the "next" pagination element echo $paginator->next();

// Create the "next" pagination element with custom text
echo $paginator->next('Skip Forwards');

Parameters

string $text

Returns

string

Tags

None found

appends()

appends(array  $values) : \Laravel\Paginator

Set the items that should be appended to the link query strings.

Parameters

array $values

Returns

LaravelPaginator

Tags

None found

speaks()

speaks(string  $language) : \Laravel\Paginator

Set the language that should be used when creating the pagination links.

Parameters

string $language

Returns

LaravelPaginator

Tags

None found

__construct()

__construct(array  $results, integer  $page, integer  $total, integer  $per_page, integer  $last) : void

Create a new Paginator instance.

Parameters

array $results
integer $page
integer $total
integer $per_page
integer $last

Tags

None found

valid()

valid(integer  $page) : boolean

Determine if a given page number is a valid page.

A valid page must be greater than or equal to one and a valid integer.

Parameters

integer $page

Returns

boolean

static

Tags

None found

element()

element(string  $element, integer  $page, string  $text, \Laravel\Closure  $disabled) : string

Create a chronological pagination element, such as a "previous" or "next" link.

Parameters

string $element
integer $page
string $text
LaravelClosure $disabled

Returns

string

Tags

None found

beginning()

beginning() : string

Build the first two page links for a sliding page range.

Returns

string

Tags

None found

ending()

ending() : string

Build the last two page links for a sliding page range.

Returns

string

Tags

None found

range()

range(integer  $start, integer  $end) : string

Build a range of numeric pagination links.

For the current page, an HTML span element will be generated instead of a link.

Parameters

integer $start
integer $end

Returns

string

Tags

None found

link()

link(integer  $page, string  $text, string  $class) : string

Create a HTML page link.

Parameters

integer $page
string $text
string $class

Returns

string

Tags

None found

appendage()

appendage(array  $appends) : string

Create the "appendage" to be attached to every pagination link.

Parameters

array $appends

Returns

string

Tags

None found