1$data = [
2 ['user_id'=>'Coder 1', 'subject_id'=> 4096],
3 ['user_id'=>'Coder 2', 'subject_id'=> 2048],
4 //...
5];
6
7Model::insert($data); // Eloquent approach
8DB::table('table')->insert($data); // Query Builder approach
9
1/*
2It is really easy to do a bulk insert in Laravel with or without the query builder.
3You can use the following official approach.
4*/
5
6
7Entity::upsert([
8 ['name' => 'Pierre Yem Mback', 'city' => 'Eseka', 'salary' => 10000000],
9 ['name' => 'Dial rock 360', 'city' => 'Yaounde', 'salary' => 20000000],
10 ['name' => 'Ndibou La Menace', 'city' => 'Dakar', 'salary' => 40000000]
11], ['name', 'city'], ['salary']);