TIP 06 / 08

Useful for() Method.

The Laravel factory has a very useful for() method. You can use it to create belongsTo() relationships.

code
public function run()
{
    Product::factory()
        ->count(3)
        ->for(Category::factory()->create())
        ->create();
}