If you wish to insert data in the MySQL database using core sql query or want to insert using DB statement in the laravel this post example will help you.
In this post I am inserting data in the database using DB::statment(), Query builder in the laravel allows us to accept core SQL query statements to execute and insert data in the MySQL database.
Here I am providing an example of laravel query builder DB::statment(), I have an India state which having in core SQL query base so I want to insert directly using the laravel query builder. see below example of how to insert in laravel.
DB::statement("INSERT INTO `states` ( `name`, `district`, `delivery`, `created_at`, `updated_at` ) VALUES ('Andhra Pradesh', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00'), ('Arunachal Pradesh', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00'), ('Assam', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00'), ('Bihar', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00'), ('Chhattisgarh', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00'), ('Goa', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00'), ('Gujarat', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00'), ('Haryana', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00'), ('Himachal Pradesh', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00'), ('Jammu and Kashmir', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00'), ('Jharkhand', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00'), ('Karnataka', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00'), ('Kerala', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00'), ('Madhya Pradesh', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00'), ('Maharashtra', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00'), ('Manipur', NULL, 'Yes','2022-11-23 12:00:00','2022-11-23 12:00:00')");
We always thanks to you for reading our blogs.

Dharmesh Chauhan
(Swapinfoway Founder)Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us

Haresh Chauhan
(Co-Founder)We Are Also Recommending You :
- How To Add Active Class To Menu Item In Laravel
- Firebase Dynamic Links Shorten URL PHP Function
- Route Resource Controller Laravel
- Laravel Zaakpay Payment Gateway Integration Tutorial Example
- Laravel 10 Breeze Integration Tutorial Example
- Laravel 9 Authorize.Net Payment Gateway Integration
- How to Integrate Razorpay Payment Gateway in Laravel 9 Example
- Unique violation: 7 ERROR: duplicate key value violates unique constraint "users_pkey" DETAIL: Key (id)=(1) already exists.
- Looping Variable Laravel Blade File - $loop
- UPI Payment Gateway Integration in PHP/Laravel