Laravel - Working with the database

Laravel has made database handling very easy. Laravel currently supports the following 4 databases −
- MySQL
- postgres
- SQLite
- SQL Server
The database query can be run using raw SQL, a free query builder and Eloquent ORM. To understand all CRUD (Create, Read, Update, Delete) operations with Laravel, we will use a simple student management system.
Database connection
Configure the database in the config/database.php file and create a college database with a structure in MySQL as shown in the following table.
Database: College
Desk: student
Column name | Column type | additional |
---|---|---|
I'd | INT (11) | Primary key | Auto increment |
title |
VARCHAR(25) |
We will see how to add, delete, update and retrieve records from the database using Laravel on the student table.
We can insert a record using the database facade with the insert method.
After setting up the database, we can retrieve the records using the database facade with the select method.
We can update records using a database facade with an update method.
We can delete a record using the database facade with the delete method.