Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,34 @@ public function createManyQuietly(iterable $records)
return Model::withoutEvents(fn () => $this->createMany($records));
}

/**
* Create a Collection of new instances of the related model, allowing mass-assignment.
*
* @param iterable $records
* @return \Illuminate\Database\Eloquent\Collection<int, TRelatedModel>
*/
public function forceCreateMany(iterable $records)
{
$instances = $this->related->newCollection();

foreach ($records as $record) {
$instances->push($this->forceCreate($record));
}

return $instances;
}

/**
* Create a Collection of new instances of the related model, allowing mass-assignment and without raising any events to the parent model.
*
* @param iterable $records
* @return \Illuminate\Database\Eloquent\Collection<int, TRelatedModel>
*/
public function forceCreateManyQuietly(iterable $records)
{
return Model::withoutEvents(fn () => $this->forceCreateMany($records));
}

/**
* Set the foreign ID for creating a related model.
*
Expand Down
Loading