It is very painful to use pagination in other framework but In laravel 4.x. It is very easy to implement pagination in laravel 4.x. By using configuration option in
app/config/view.php
file. Pagination option specifies that which view file is used for pagination.
In laravel we have by default 2 type of views.
*) Pagination::slider
*) Pagination::simple
Using Pagination with Query
We have paginate method for implement pagination in laravel 4.x.
Example
$examples = DB::table('users')->paginate(15);
In View
<div class="container">
<?php foreach ($examples as $example): ?>
<?php echo $example->name; ?>
<?php endforeach; ?>
</div>
<?php echo $examples->links(); ?>
Here link is used to create pagination link.
There are many more additional methods such as
- getCurrentPage
- getLastPage
- getPerPage
- getTotal
- getFrom
- getTo
- count
0 Comment(s)