Here is the syntax for how I'm doing it right now for a project...
// create discussions explicitly for me
$user_count = User::count();
foreach (range(1, 10) as $i) {
Discussion::factory()
->has(
Reply::factory()
->count(rand(1, 12))
->state(new Sequence(
fn($sequence) => [
'user_id' => rand(1, $user_count),
'replyable_id' => $i,
'replyable_type' => Discussion::class,
])
)
)
->hasVotes(rand(1, 22))
->create([ 'user_id' => 1 ]);
}
then one more loop for general not specific to my user.