Pagination in Laravel | How to add pagination in your Laravel Application?
In this short tutorial I'm gonna discuss about How you can add pagination in your laravel application.
Already I have said that it's a short tutorial, so don't waste out time and let's begin:
1. You all you have might known how can you get all the user data from database in controller..right?
Just writing the below line:
$user = User::all();
Now we gonna make a simple change on the above line.We'll replace it with it:
$user = User::paginate(15);
/*We want to show 15 rows data in every page*/
2. Our task is almost done. Just write the below at the bottom of the table tag in which page you want to show.
{{$user->render()}}
3. That's it. You will see a nice pagination in your view page like this:
Thanks for staying with me for the whole session. Hope you enjoy it and stay connected with my blog.
0 comments:
Post a Comment