Skip to content

[12.x] Add makeMany method to Factory#58795

Merged
taylorotwell merged 3 commits intolaravel:12.xfrom
jackbayliss:12.x-make-many-factory-method
Feb 13, 2026
Merged

[12.x] Add makeMany method to Factory#58795
taylorotwell merged 3 commits intolaravel:12.xfrom
jackbayliss:12.x-make-many-factory-method

Conversation

@jackbayliss
Copy link
Contributor

@jackbayliss jackbayliss commented Feb 13, 2026

We can createMany, but cant makeMany,

This PR adds makeMany which is basically the same as createMany but calls make underneath.

Seemed an easy enough change and easy to maintain.

This is generally useful for assertions where we don't need the database.

// This works fine - and goes to the db
$tags = Tag::factory()->createMany([
    ['name' => 'I'],
    ['name' => 'Am'],
    ['name' => 'Fake'],
]); 

// No DB, but currently we do... 
$tags = Tag::factory()->forEachSequence(
    ['name' => 'I'],
    ['name' => 'Am'],
    ['name' => 'Fake'],
)->make();

// With this PR we unlock... 
$tags = Tag::factory()->makeMany([
    ['name' => 'I'],
    ['name' => 'Am'],
    ['name' => 'Fake'],
]);

@github-actions
Copy link

Thanks for submitting a PR!

Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@jackbayliss jackbayliss marked this pull request as ready for review February 13, 2026 11:14
@taylorotwell taylorotwell merged commit f5787a3 into laravel:12.x Feb 13, 2026
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments