I am having a bit of trouble transitioning from TestDummy to the new Model Factories. How do you create the related model factories. Let's say you have users and companies. Each company is owned by 1 user. How do I go creating the user_id field?
You may even persist multiple models to the database. In this example, we'll even attach a relation to the created models. When using the create method to create multiple models, an Eloquent collection instance is returned, allowing you to use any of the convenient functions provided by the collection, such as each:
@mstnorris@prodigy10
Be wary of using 'profile_id' => $factory->create('App\Profile')->id in your factory definitions. It works fine but if you need to override the profile_id value the original definition ($factory->create('App\Profile')->id) will still be created first before your override is merged in and may cause issues for you later on. I've raised this issue on github https://github.com/laravel/framework/issues/9245 but have not heard a response yet.
@devinfd I saw your issue on GitHub and I hope that is sorted soon. While it is still in development it shouldn't be an issue, and unless you are writing 100s of these things then whatever solution they go with, I'm sure it can be swapped out.
@mstnorris the "newer syntax" was not a minor detail, if I would have known the "newer syntax" I would not have opened the question in the first place.