In Laravel 11 application, paginate() is a built-in method using which you can display records in HTML table data with paginated numbers and links.
Let’s start creating an application that displays data in an HTML table view with pagination with numbers and links using Bootstrap and the paginate() method:
Step 1 – Add Dummy Data in DB
Run the following commands on cmd to generate dummy records in database table:
Step 2 – Define Routes
Edit the routes/web.php
file, and define routes in it to handle pagination data requests:
Step 3 – Create Controller
Run the following command to create a controller class to handle pagination data from database logic in it:
Edit app/Http/Controllers/UserController.php file, and implement method in it to handle pagination data from database table:
Step 4 – Create Blade File
Go to resources/views directory and create users.blade.php file, and then display paginated data in it:
Step 5 – Test This Application
Run the following command to start application server:
php artisan serve
Type http://localhost:8000/users
url on browser to test this application.