Getting class does not exist error when running database seeder

Make sure your AdminsTableSeeder.php file is in the same directory where you have your DatabaseSeeder.php file.

Run

composer dump-autoload

then try

php artisan db:seed

Optional.

class DatabaseSeeder extends Seeder
{
     /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run(){
        $this->call('AdminsTableSeeder');
    }
}

try with $this->call('AdminsTableSeeder'); like this.


In your case, move all seeder files from previous database/seeds directory to database/seeders folder & then run composer dump-autoload.


Remember, from laravel 8 seeders and factories are namespaced

To accommodate for these changes,

[1] - Add Database\Seeders namespace to your seeder classes.

 namespace Database\Seeders;

[2] - Move all seeder files to database/seeders folder.

[3] - If you import any seeders classes in DatabaseSeeder file then remove all of them. (simply remove all lines that started with use Database\Seeders\... from DatabaseSeeder.php)

[4] - Finally run dump-autoload.

composer dump-autoload

You can now try a fresh migration with seed,

php artisan migrate:fresh --seed