How to fetch/retrieve data from database in Laravel 8
How to fetch/retrieve data from database in Laravel 8
In this post, you will learn how to fetch / retrieve data from database in laravel where we will be using Bootstrap 5 version to design the user interface which is to design the HTML table to display the data from database using eloquent model in laravel.
So before getting started, Create a new laravel project and give the Database Connection in .env file.
Step 1: To fetch the data from database you have been already created a Model and Migration and a Controller in laravel application:
Step 2: Give a route to call the function in your controller for calling the page in the following path: routes/web.php as follows:
Step 3: Let's go to the controller in the following path : app/Http/Controllers/StudentController.php file.
Step 4: Create a blade file named index.blade.php inside student folder as the following path: resources/views/student/index.blade.php file as follows:
Now, you can successfully run the application by the following command:
now lets go to the browser at the link: http://localhost:8000/students
Thanks for reading...