Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

1 switch KEY OFF/ON for table before and after inserting 2 use \DB::insert() instead of \Eloquent

0

Why do you need to store it uing Eloquent? Yes, it's not the best approach, it will be time and resource consuming.

The best way would be inserting in chunks using simple insert method:

foreach ($chunks as $chunk)
{
  DB::table('your_table')->insert($chunk); // single insert query
}

If you have 1k rows to insert, I suppose you can do it in one go, but for more I would do it like above.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

richbreton richbreton Joined 19 Nov 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.