You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
createMany function of Illuminate\Database\Eloquent\Factories\Factory accepts any iterable variable as its first argument. It then tries to pass it to array_map which accepts only arrays.
/**
* Create a collection of models and persist them to the database.
*
* @param iterable $records
* @return \Illuminate\Database\Eloquent\Collection
*/
public function createMany(iterable $records)
{
return new EloquentCollection(
array_map(function ($record) {
return $this->state($record)->create();
}, $records)
);
}
Description:
createMany function of Illuminate\Database\Eloquent\Factories\Factory accepts any iterable variable as its first argument. It then tries to pass it to array_map which accepts only arrays.
Steps To Reproduce:
$modelWithFactory::factory()->createMany(collect([['foo' => 'bar'],['foo' => 'baz']]));
The model and factory is irrelevant, the code will produce the following PHP error before getting anywhere regardless
array_map(): Argument #2 ($array) must be of type array, Illuminate\Support\Collection given
The text was updated successfully, but these errors were encountered: