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?
Maybe it is too late, but I would like to share another custom pagination template I made that creates a first/next and last/previous links. It also hides the links when the user is in the first/last page already.
(Optional) You can also determine the interval of links (the number of links before and after the current page)
Usage example:
or
Here is the gist: https://gist.github.com/carloscarucce/33f6082d009c20f77499252b89c35dea
And the code:
Whereas in Laravel 4.2 I would use:
In Laravel 5 you can replicate the above with the following:
Now in the included view,
$object
will have the pagination methods available, such ascurrentPage()
,lastPage()
,perPage()
, etc.You can view all methods available at http://laravel.com/docs/5.0/pagination
Laravel 5.2 uses presenters for this. You can create custom presenters or use the predefined ones. Laravel 5.2 uses the
BootstrapThreePrensenter
out-of-the-box, but it's easy to use theBootstrapFroutPresenter
or any other custom presenters for that matter.In your blade template, you can use the following formula:
For creating custom presenters I recommend watching Codecourse's video about this.
In Laravel 5.4
The easiest way I found, by exporting them to your
resources/views/vendor
directory using thevendor:publish
commandphp artisan vendor:publish --tag=laravel-pagination
and than go to
resources\views\vendor\pagination\default.blade.php
and do your customization there.
Full documentation about this can be found here
Here is an easy solution of customized Laravel pagination both server and client side code is included.
Assuming using Laravel 5.2 and the following included view:
@include('pagination.default', ['pager' => $data])
Features
default.blade.php
Server Side Controller Function
For Laravel 5.3 (and may be in other 5.X versions) put custom pagination code in you view folder.
then call this pagination view file from the main view file as
Update the pagination/default.blade.php however you want
It works in 6.x versions as well.