Database: Pagination

Kiaan's paginator is integrated with the query builder and Eloquent ORM and provides convenient, easy-to-use pagination of database records with zero configuration.

Number of rows per page

Use page() method for pagination system.

The first parameter accepts the number of rows on the page.

$users = DB::table("users")->page(10);

foreach ($users as $key => $user) {
    echo "$user->name <hr>";
}

Go to page

The second parameter goes to the specified page.

$users = DB::table("users")->page(10, 2);

foreach ($users as $key => $user) {
    echo "$user->name <hr>";
}

Pagination system

The page property is used to obtain pagination data.

$users = DB::table("users")->page(1, 2);

print_r($users->page);

# Output
stdClass Object ( [pages] => 2 [current] => 2 [total] => 2 [count] => 1 [next] => 0 [back] => 1 )

Last updated