-
Notifications
You must be signed in to change notification settings - Fork 79
Description
Hi @JeffreyWay
If theres a way to do this and I've missed it apologies...
TestDummy creates a new model instance for every relation specified, this is okay, but it would be awesome if there was some way to specify whether existing seeded data should be used to populate the relation based on a previously seeded model.
For example, when using TestDummy for seeding creating 50 of a User factory, 100 of a Project factory, which has two references to User - created_by / completed_by ends up with 250 inserts to Users, for the amount you requested, plus 100 for each of the relations. This grows exponentially when trying to populate pivot tables as well, and doesn't really reflect pivot data that well.
I propose adding another string like 'factory:App\User' that could be something like 'model:App\User' that could get a count of existing Models and use Faker's numberBetween method to generate a relationship integer, or something to that effect.
I would be happy to submit a PR.