In Laravel Eloquent, you can insert multiple rows into a database table using the insert method on the query builder. Here's an example:
$data = [ ['name' => 'John', 'email' => 'john@example.com'],
['name' => 'Jane', 'email' => 'jane@example.com'],
['name' => 'Jim', 'email' => 'jim@example.com'],
];
\DB::table('users')->insert($data);
This will insert three new rows into the users table, with the values specified in the $data array. Note that the \DB facade is used here to create an instance of the query builder, which can be used to interact with the database directly.
Tags:
laravel