Bird
0
0

How can you modify a seeder to run another seeder inside it, for example, to run RoleSeeder from UserSeeder?

hard📝 Application Q9 of 15
Laravel - Database Basics and Migrations
How can you modify a seeder to run another seeder inside it, for example, to run RoleSeeder from UserSeeder?
ARoleSeeder::run();
B$this->call(RoleSeeder::class);
CcallSeeder('RoleSeeder');
DrunSeeder(RoleSeeder);
Step-by-Step Solution
Solution:
  1. Step 1: Recall Seeder Calling Method

    Inside a seeder, use $this->call(SeederClass::class) to run another seeder.
  2. Step 2: Verify Other Options Are Invalid

    Directly calling run() or using callSeeder/runSeeder are not Laravel methods.
  3. Final Answer:

    $this->call(RoleSeeder::class); -> Option B
  4. Quick Check:

    Use $this->call() to run other seeders [OK]
Quick Trick: Use $this->call(ClassName::class) inside seeders [OK]
Common Mistakes:
  • Calling run() directly
  • Using non-existent callSeeder functions
  • Passing string instead of class reference

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes