laravel / ideas

Issues board used for Laravel internals discussions.
938 stars 28 forks source link

Add createMany method for Models. #2498

Open farzinghanbari opened 3 years ago

farzinghanbari commented 3 years ago

Add a new method to create multiple records by invoking a method.

marifuli commented 3 years ago

are you talking about the Eloquent methods?

rimace commented 3 years ago

What problem would be solved that currently exists? Can you make an example? Do you mean like fire one query with that method call?

danilopolani commented 3 years ago

+1, for two simple reasons:

  1. ::insert() is not reliable, because it does not consider fillable, mutators and does not add timestamps.
  2. You run just a query instead of N+1.

Duplicate: https://github.com/laravel/ideas/issues/1334