I have a factory:
factory(Survey::class, 3)->create()->each(function ($survey)
{
factory(Question::class, 1)
->create()
->each(function ($question)
{
factory(Option::class, rand(2,3))->create();
});
});
The problem is - I need to add an index
to every option. It should be 1,2,3...
How can I add iterator to ->each() function?
I've tried to add variables inside body of the loop, but in not works as for/foreach one.
ANy ideas?