Level 104
What is the context here - do you use the User Factory to create the $user? If yes, then you can create the posts using the magic hasXXX method:
User::factory()->hasPosts(3)->create([/* attributes */])
Is there a way to chain from a relation to a factory? e.g.
$user->posts()->factory()->count(3)->create()
What is the context here - do you use the User Factory to create the $user? If yes, then you can create the posts using the magic hasXXX method:
User::factory()->hasPosts(3)->create([/* attributes */])
Please or to participate in this conversation.