File tree 1 file changed +28
-0
lines changed
src/Illuminate/Database/Eloquent/Relations
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -436,6 +436,34 @@ public function createManyQuietly(iterable $records)
436
436
return Model::withoutEvents (fn () => $ this ->createMany ($ records ));
437
437
}
438
438
439
+ /**
440
+ * Create a Collection of new instances of the related model, allowing mass-assignment.
441
+ *
442
+ * @param iterable $records
443
+ * @return \Illuminate\Database\Eloquent\Collection<int, TRelatedModel>
444
+ */
445
+ public function forceCreateMany (iterable $ records )
446
+ {
447
+ $ instances = $ this ->related ->newCollection ();
448
+
449
+ foreach ($ records as $ record ) {
450
+ $ instances ->push ($ this ->forceCreate ($ record ));
451
+ }
452
+
453
+ return $ instances ;
454
+ }
455
+
456
+ /**
457
+ * Create a Collection of new instances of the related model, allowing mass-assignment and without raising any events to the parent model.
458
+ *
459
+ * @param iterable $records
460
+ * @return \Illuminate\Database\Eloquent\Collection<int, TRelatedModel>
461
+ */
462
+ public function forceCreateManyQuietly (iterable $ records )
463
+ {
464
+ return Model::withoutEvents (fn () => $ this ->forceCreateMany ($ records ));
465
+ }
466
+
439
467
/**
440
468
* Set the foreign ID for creating a related model.
441
469
*
You can’t perform that action at this time.
0 commit comments