You can specify dependencies in the run()
method of your seeder.
1class DatabaseSeeder extends Seeder 2{ 3 public function run() 4 { 5 $user = User::factory()->create(); 6 7 $this->callWith(EventSeeder::class, [ 8 'user' => $user 9 ]);10 }11}
1class EventSeeder extends Seeder 2{ 3 public function run(User $user) 4 { 5 Event::factory() 6 ->when($user, fn($f) => $f->for('user')) 7 ->for(Program::factory()) 8 ->create(); 9 }10}
Tip given by @justsanjit