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?
3 Answers
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
1 Comment
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/vendordirectory using thevendor:publishcommand:
php artisan vendor:publish --tag=laravel-paginationThis command will place the views in the
resources/views/vendor/paginationdirectory. Thedefault.blade.phpfile 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.
Comments
You need to publish the views first with php artisan vendor:publish --tag=laravel-pagination then they will appear in your resources/views/vendor/pagination folder and you can override them. Here is the reference
This command will place the views in the
resources/views/vendor/paginationdirectory. The default.blade.php file within this directory corresponds to the default pagination view. Simply edit this file to modify the pagination HTML.