Level 41
'user_id' => factory(App\User::class)->create()->id,
2 likes
I am playing withe the new Model Factory feature, but I don't know how to use relationship in it.
In my project a User has may Status(es) and a Status belongs to a User
This is my ModelFactory.php file:
$factory->define(App\User::class, function ($faker) {
return [
'name' => $faker->name,
'email' => $faker->email,
'password' => str_random(10),
'remember_token' => str_random(10),
];
});
$factory->define(App\Status::class, function ($faker) {
return [
'body' => $faker->sentence,
'user_id' => /* WHAT DO I WRITE HERE? */,
];
});
What do I write for user_id ?
Please or to participate in this conversation.