I'm creating test by PHP Unit on Lumen. I try to pass variable $name to related factory Template --> Attribute.
I have tried this code but not working.
$name = 'Mulyawan Sentosa';
factory(TemplateModel::class)->create(
[
'id' => 12
]
)->each(
function ($template) {
$template->attributes()->save(
factory(TemplateattributeModel::class)->make(
[
'name' => $name
]
)
);
}
);
How to do this? Thank you!