-1

I have a range of postal codes. Maybe 30000 - 40000 < this is exactly like my request is looking. If I want to save all numbers 30000,30001,30002 .... 40000. My Controller get's very low and it takes a lot of time.

Is there any solution to save this very fast with createMany?

I start with explode to get from and to.

$areas[] = explode(' - ', $areaView['areas']);

How has my next step to look like and save 10000 entries very fast?

Edit: createMany is not running, because of timeout.

Maik Lowrey
  • 10,972
  • 4
  • 14
  • 43
SaschaK
  • 137
  • 12
  • does this answer your question? https://stackoverflow.com/questions/57339658/how-to-insert-multiple-records-with-createmany-method-in-laravel – Maksim Nov 16 '21 at 12:12
  • 1
    Can you edit your question to provide a bit of code for context ? Your controller method would be nice – YannPl Nov 16 '21 at 15:03
  • Does this answer your question? [How to insert multiple records with createMany method in laravel](https://stackoverflow.com/questions/57339658/how-to-insert-multiple-records-with-createmany-method-in-laravel) – SuperDJ Nov 16 '21 at 16:12
  • No answer until yet is successfull, because if more than 3000 relationsships are created with createMany. Script runs into timeout. – SaschaK Nov 18 '21 at 08:17

1 Answers1

-2

Try using database directly instead of model. DB::table('postal_code')->create($array_data);