Laravel Pagination
shani singh
Posted on June 18, 2021
In this post I am going to explain you about using pagination with bootstrap.
Laravel By default come with Tailwind CSS Pagination Component. To use the Bootstrap Pagination We need to change the AppServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Pagination\Paginator;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Paginator::useBootstrap();
}
}
To make a collection object pagination friendly we need to use pagination methods.
To use The Simple Pagination we can update the controller.
$users = User::select('id', 'email', 'name')->simplePaginate(5);
In List View table we can simply output the pagination links
{{ $users->links() }}
For Pagination with numbers we need to change the collection pagination method.
$users = User::select('id', 'email', 'name')->paginate(5);
Get Code on Techtool Github
You can watch this video I have explained this.
Thank You for Reading
Reach Out To me.
Twitter
Instagram
TechToolIndia
Posted on June 18, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
October 31, 2022