Laravel 4.2 has the option to specify a custom view in app/config/view.php
such as:
/*
|--------------------------------------------------------------------------
| Pagination View
|--------------------------------------------------------------------------
|
| This view will be used to render the pagination link output, and can
| be easily customized here to show any view you like. A clean view
| compatible with Twitter's Bootstrap is given to you by default.
|
*/
'pagination' => 'pagination_slider-alt'
This is gone in Laravel 5 at least regarding view.php
.
Is there a way to replicate this behavior in Laravel 5?
Hi there is my code for pagination: Use in blade @include('pagination.default', ['paginator' => $users])
Views/pagination/default.blade.php
Here's one for Laravel 5, Bootstrap 4 and without Blade syntax (for those who find it infinitely harder to read).
To use, instead of:
Use:
Where
partials/pagination
is your blade template file with the below contents pasted in.beside the answer of @MantasD I would like to offer comprehensive customized Laravel pagination. Assuming using Laravel 5.2 and the following included view:
Features
default.blade.php
PaginationStartEnd function
You can use and customize this more as you wish.
Note: $pager->paging is variable set to 0 declared in the controller action
I use this code with k7 theme and use this code with their built in class. You can also use this code with your theme and your class as you need..
try to do this.
In Laravel 5.3+ use
In Laravel 5.0 - 5.2 instead of
use
views/pagination/default.blade.php
That's it.
If you have a lot of pages, use this template:
views/pagination/limit_links.blade.php
In Laravel 5 custom pagination is based on presenters (classes) instead of views.
Assuming in your routed code you have
In L4 you used to do something like this in your views:
In L5 you do instead:
The
render()
method accepts anIlluminate\Contracts\Pagination\Presenter
instance. You can create a custom class that implements that contract and pass it to therender()
method. Note thatPresenter
is an interface, not a class, therefore you must implement it, not extend it. That's why you are getting the error.Alternatively you can extend the Laravel paginator (in order to use its pagination logic) and then pass the existing pagination instance (
$users->...
) to you extended class constructor. This is indeed what I did for creating my custom Zurb Foundation presenter based on the Bootstrap presenter provided by Laravel. It uses all the Laravel pagination logic and only overrides the rendering methods.With my custom presenter my views look like this:
And my customized pagination presenter is: