由于这个“新”更新出现在 laravel(laravel 8)中,我正在与工厂作斗争。我需要有关如何将用户模型中的唯一 ID 提供给配置文件工厂中的 user_id 列的帮助。在我的用户模型中,我与个人资料有关系:
public function profile()
{
return $this->hasOne(Profile::class);
}
在轮廓模型中:
public function user()
{
return $this->belongsTo(User::class);
}
现在我必须向配置文件工厂提供数据:
return [
'user_id' => ,
'image' => 'image',
'bio' => $this->faker->sentence,
...