When using factories with relationships, Laravel also provides magic methods.
1// magic factory relationship methods2User::factory()->hasPosts(3)->create();3 4// instead of5User::factory()->has(Post::factory()->count(3))->create();
Tip given by @oliverds_