Turn Your Vehicle Into a Smart Earning Asset

While you’re not driving your car or bike, it can still be working for you. MOTOSHARE helps you earn passive income by connecting your vehicle with trusted renters in your city.

🚗 You set the rental price
🔐 Secure bookings with verified renters
📍 Track your vehicle with GPS integration
💰 Start earning within 48 hours

Join as a Partner Today

It’s simple, safe, and rewarding. Your vehicle. Your rules. Your earnings.

How to Insert and Retrieve Data in Database – Laravel Framework

In this example, I am going to show you how to insert data in the database using laravel framework PHP.

First, creating table the SQL query:

CREATE TABLE student_details
(
id int NOT NULL AUTO_INCREMENT,
first_name varchar(50),
last_name varchar(50),
city_name varchar(50),
email varchar(50),
PRIMARY KEY (id)
);Code language: PHP (php)

Now, create three file for insert data in Laravel.

Step 1. Create a controller name as StudInsertController.php.
The file location is : (app/Http/Controllers/StudInsertController.php)

Step 2. Create view page name as stud_create.php
The file location is: (resources/views/stud_create.php)

Then put this code in your StudInsertController.php.

Then put this code in your stud_create.blade.php.

Step 3. Then go to routes as web.php and put this code.
The file location is : (routes/web.php)

Route::get('insert','StudInsertController@insertform');
Route::post('create','StudInsertController@insert');Code language: PHP (php)

Then, you can see the data is inserted.

So, the data is inserted in the database, then we need to retrieve a record or data from the MySQL database.

Step 4. Create a controller for view name as StudViewController.php.
The file location is : (app/Http/Controllers/StudViewController.php)

Step 5. Create a view page name as stud_view.blade.php.
The file location is : (resources/views/stud_view.blade.php).

Then put this code StudViewController.php.

Then, retrieve the students data then put this code stud_view.blade.php.

Step 6. Then go to routes as web.php and put this code.
The file location is (routes/web.php)

Route::get('view-records','StudViewController@index');Code language: PHP (php)

Then, you can see the view page.

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.