class Pagination

Class that supports pagination for views.

Methods

__construct(int $currentPage = 1, int $limit = 10, int $totalItems = 0)

Constructor for Pagination class

static int|string
currentPage(object $request)

Retrieves current page from GET request.

int
offset()

Calculates offset needed for pagination.

static string
pagination(int $current_page, int $total_pages, string $base_url = '?page=')

Renders Bootstrap 5 pagination controls.

array
paginationParams(mixed $conditions, array $bind = [], string $order)

Builds parameters for pagination query.

int
totalPages()

Returns total number of pages we need to handle.

Details

at line 20
__construct(int $currentPage = 1, int $limit = 10, int $totalItems = 0)

Constructor for Pagination class

Parameters

int $currentPage

The current page that is selected.

int $limit

The maximum number of items for a page.

int $totalItems

The total number of items for a list

at line 32
static int|string currentPage(object $request)

Retrieves current page from GET request.

Parameters

object $request

The request object.

Return Value

int|string

The current page number.

at line 42
int offset()

Calculates offset needed for pagination.

Return Value

int

The offset

at line 55
static string pagination(int $current_page, int $total_pages, string $base_url = '?page=')

Renders Bootstrap 5 pagination controls.

Parameters

int $current_page

The current page number.

int $total_pages

The total number of pages.

string $base_url

The base URL for pagination links. Default is '?page='.

Return Value

string

The HTML markup for the pagination controls.

at line 114
array paginationParams(mixed $conditions, array $bind = [], string $order)

Builds parameters for pagination query.

Parameters

mixed $conditions

The conditions for the query.

array $bind

What we want to bind.

string $order

The order we want the results returned.

Return Value

array

An array of params tailored for pagination.

at line 129
int totalPages()

Returns total number of pages we need to handle.

Return Value

int

The total number of pages to be manged by pagination.