- Comment BELONGSTO Post
- Comment BELONGSTO User
- Post BELONGSTO User
- Post BELONGSTOMANY Category
- Category BELONGSTO User
When you call
factory(\App\Comment::class)->create();
It will generate a Comment, Post, Category. All belonging to the same User. The Category will also be related to the Post.
P.S. Depending on the scenario, I'd consider using something more organized like "Model Factory Stories" https://github.com/jeffochoa/factory-stories