Laravel - Working with the database
Laravel has made database handling very easy. Laravel currently supports the following 4 databases −
- 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.
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.
|Column name||Column type||additional|
|I'd||INT (11)||Primary key | Auto increment|
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.