我正在 Lumen 上通过 PHP Unit 创建测试。我尝试将变量 $name 传递给相关的工厂模板 --> 属性。
我试过这段代码但没有用。
$name = 'Mulyawan Sentosa';
factory(TemplateModel::class)->create(
[
'id' => 12
]
)->each(
function ($template) {
$template->attributes()->save(
factory(TemplateattributeModel::class)->make(
[
'name' => $name
]
)
);
}
);
这该怎么做?谢谢!
忽然笑