I'm building an app with Laravel 5.5. and I need to customize the pagination. I have to apply css class on the page link elements. Where I find the template to override?
The pagination option specifies which view should be used to create pagination links. By default, Laravel includes two views. The pagination::slider view will show an intelligent "range" of links based on the current page, while the pagination::simple view will simply show "previous" and "next" buttons.
Use Pagination in Laravel Implementing pagination in laravel is smooth, add the laravel paginate function in the getData() function inside the EmployeeController class. Remove all() and use paginate() and it takes a number as an argument, that number defines the number of results to be shown to the user.
You have to launch this command from terminal:
php artisan vendor:publish --tag=laravel-pagination
This creates the views in the resources/views/vendor/pagination
directory.
Now you can apply your classes in the view: default.blade.php
.
Read the documentation here: https://laravel.com/docs/5.6/pagination#customizing-the-pagination-view
You can specify your own pagination view:
{{ $paginator->links('view.name') }}
From the docs:
By default, the views rendered to display the pagination links are compatible with the Bootstrap CSS framework. However, if you are not using Bootstrap, you are free to define your own views to render these links. When calling the links method on a paginator instance, pass the view name as the first argument to the method
Or you can customize the default view.
From the docs:
However, the easiest way to customize the pagination views is by exporting them to your
resources/views/vendor
directory using thevendor:publish
command:
php artisan vendor:publish --tag=laravel-pagination
This command will place the views in the
resources/views/vendor/pagination
directory. Thedefault.blade.php
file within this directory corresponds to the default pagination view. Edit this file to modify the pagination HTML.
Or, if you've just modified default Bootstrap classes, you can just load CSS after Bootstrap is loaded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With