I am creating an Admin auth to my app and I generated the model with the artisan command:
php artisan make:model Admin -m
This is the generated class:
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Admin extends Model
{
//
}
This created an empty model and a basic migration. I added this lines to the migration:
public function up()
{
Schema::create('admins', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 32);
$table->string('username', 32);
$table->string('email', 320);
$table->string('password', 64);
$table->string('remember_token', 100)->nullable();
$table->timestamps();
});
}
Then I used the command line to create a seeder:
php artisan make:seeder AdminTableSeeder
And added the seeder to the DatabaseSeeder
public function run()
{
$this->call(AdminTableSeeder::class);
}
But when I run the seeder php artisan db:seed
I get a class missing error:
PHP Fatal error: Class 'Admin' not found in /laravelpath/database/seeds/AdminTableSeeder.php on line 15
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Admin' not found
It seems to be the Admin model.
I've tried to run the fixes composer update
and composer dump-autoload
but they didn't help.
Anyone knows what is happening? Why do I get this error and how do I fix it?
Extra info: I read somewhere that I should name my app so I executed php artisan app:name MyAppName
and it added namespaces everywhere (at least in the Http
folder). I'm not sure if it messed up my classes.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire