Laravel 8 CRUD Tutorial: Manage Student Records
Are you looking to build a simple yet powerful CRUD (Create, Read, Update, Delete) application in Laravel 8? In this tutorial, we'll walk through how to create a Laravel 8 app to manage student records with full functionality: create, list, update, and delete.
Whether you're a beginner or brushing up on your Laravel skills, this guide is for you!
Step 1: Install Laravel 8 Project
Start by creating a fresh Laravel 8 project using Composer:
Step 2: Configure Database
Update your .env
file with your database credentials:
Make sure to create the database (student_db
) using phpMyAdmin or MySQL CLI.
Step 3: Create Student Model and Migration
Run this command:
Then open the migration file in database/migrations/
and update it like this:
Now run the migration:
Step 4: Define Fillable Fields
In app/Models/Student.php
, add:
Step 5: Setup Routes
Add these routes to your routes/web.php
:
Step 6: Create Student Controller
Generate the controller:
Update StudentController.php
:
Step 7: Create Blade Views
Layout: resources/views/layout/app.blade.php
Add Student Form: student/create.blade.php
Student List: student/list.blade.php
Edit Student: student/edit.blade.php
View Student: student/view.blade.php
Step 8: Run the Application
Then open your browser and navigate to:
Conclusion
That’s it! You’ve successfully built a complete Laravel 8 CRUD app to manage student records. You learned how to:
-
Configure database settings
-
Create migrations and models
-
Use resource controllers
-
Build dynamic Blade views
-
Perform create, read, update, and delete operations
first of all thanxs for this nice and quick tutorial. But unfortunately I wasn´t able to coomplete it and see the result. I guess that you probably made some little errors and typos while doing this. Like instruction reagrding PostController vs-StudentController and the other things is this:
Step 7: Create Blade Files
Here in this step, we create our view files. First, create two folders one is “layout” and another is “posts”. In the layout, folder creates an app.blade.php file, and inside the posts folder create another blade file. If you don’t know to integrate our blade files in Laravel then please check first here how to integrate the Laravel bootstrap admin panel. Now create below blade files for your crud app:
layout and posts folder doe go where.
--> Would be very happy if you could check this and reply&correct these.
Thanxs :)