I ran into the same problem. Laravel 5 says it can handle multiple arrays but never works.
A simple solution is to simply loop and do an insert with foreach.
foreach($data as $insert){
$id = \DB::table('tablename')->insertGetId($insert);
}
You can also wrap it in a transaction, so if one of the elements fails, they will drop everything again.
\DB::beginTransaction();
foreach($data as $insert){
$id = \DB::table('tablename')->insertGetId($insert);
if(empty($id){
Log::error('Failed to insert row into database.');
\DB::rollback();
break;
}
}
\DB::commit();
source
share