0

I have created two seeder classes 'UsersTableSeeder" and "Conferences TableSeeder". When the command "php artisan db:seed" is executed it appears:

Seeding: UsersTableSeeder

But the ConferenceTableSeeder don't work. Do you know why can be?

UsersTableSeeder:

class UsersTableSeeder extends Seeder
{
    public function run()
    {
        App\User::create([
            'name' => 'John',
            'email' => '',
            'password' => bcrypt('password')
        ]);
    }
}

ConferencesTableSeeder

class ConferencesTableSeeder extends Seeder
{

    public function run()
    {

        App\Event::create([
            'name' => 'Test name',
            'description' => '',
            'date' => '2018-03-08 06:30:00',
            ...
        ]);
    }
}
kajetons
  • 4,481
  • 4
  • 26
  • 37

2 Answers2

2

You need to add the ConferenceTableSeeder::class to the database\seeds\DatabaseSeeder.php file

public function run()
{
     $this->call(UsersTableSeeder::class);
     $this->call(ConferenceTableSeeder::class);
}

When you run php artisan db:seed it calls the run method in DatabaseSeeder class, which in turn calls the seeder files in there

The UsersTableSeeder is in there by default, that is why only that one ran

H H
  • 2,065
  • 1
  • 24
  • 30
0

Open this folder database\seeds\DatabaseSeeder.php and add the classname here to run all the seeders

write the below code to run seeder files :

public function run()
{
     $this->call(UsersTableSeeder::class);
     $this->call(ConferenceTableSeeder::class);
}

Note: you can also run a particular seeder file using the below code :

php artisan db:seed --class=ConferenceTableSeeder