This problem is not new, but I’ve looked and tried all the proposed solutions in other threads with no success. I’m working with Laravel 8 with Homestead, is a new installation on a Windows 10 machine, not an upgrade. I’m trying to seed a file called HotelSeeder.php. When I run the command
php artisan db:seed
I get the next error:
My HotelSeeder class goes like this:
My DatabaseSeeder class goes like this:
Both classes are located in the directory database/seeders
Autoload in composer.json goes like this:
After I run vagrant up and vagrant ssh, the commands that I’m running are:
php composer auto-load
php artisan db:seed
And the error shows up.
I’ve tried also:
php artisan db:seed --class=HotelSeeder
php artisan migrate:fresh –seed
php artisan clear:cache
php artisan optimize
Nothing seems to work. I hope you can help me.
Advertisement
Answer
Your seeder class is named DatabaseSeedersHotelSeeder
. In your DatabaseSeeder.php
file you should remove the alias for HotelSeeder
as that is saying you want to alias a class from the root namespace named HotelSeeder
which is not your class. If you remove that alias then the reference to HotelSeeder
will actually be your correct class, DatabaseSeedersHotelSeeder
because the current namespace of this file is DatabaseSeeders
so all class references are to that namespace.
Remove: use HotelSeeder;
Just a PHP namespacing thing.