Of course, you can always extract this to its own method in a helper class, but sometimes you may want to have each of these kinds of "stories" in its own class, even more when you need to add some extra methods to generate more complex data.
Creating new Factory Stories
After installing this package, you'll have access to a new artisan command
$ php artisan make:factory-story SomeClassName
After you run this command you should see the new file under the "database/" directory
publicfunctionbuild($params = )
// here you can add your complex model factories with their relationshipsreturnfactory(User::class)->create();
// and You can add custom methods if You need to