0

I'm trying to seed into an orders migration file, however upon using the command: php artisan migrate:refresh --seed, the following error is being returned.

ReflectionException  : Class OrdersTableSeeder does not exist

Either I'm stupid or Laravel is broken.

Seeder:

class OrdersTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        DB::table('orders')->insert([
            'user_id' => 1,
            'product_id' => 1,
            'quantity' => 10,
            'updated_at' => DB::raw('CURRENT_TIMESTAMP')
        ]);

        DB::table('orders')->insert([
            'user_id' => 1,
            'product_id' => 2,
            'quantity' => 5,
            'updated_at' => DB::raw('CURRENT_TIMESTAMP')
        ]);
    }
}

Migration:

Schema::create('orders', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->integer('user_id'); //fk
    $table->integer('product_id'); //fk
    $table->integer('quantity');
    $table->timestamps();
});
Lakhwinder Singh
  • 5,536
  • 5
  • 27
  • 52
patrickGold
  • 69
  • 1
  • 7

1 Answers1

1

Class doesn't exists error seems that Laravel couldn't find the class named OrdersTableSeeder.

I hope that using the below command helps.

composer dump-autoload

Explanation:

Why do I have to run "composer dump-autoload" command to make migrations work in laravel?

Sakthivel A R
  • 575
  • 8
  • 24