#Error in My Seeder

14 messages · Page 1 of 1 (latest)

thick bison
#

i just doing edit for my migration. and i will refresh with command php artisan migrate:refresh --seed. and I get caution error like
Illuminate\Contracts\Container\BindingResolutionException

Target class [DatabaseSeeder] does not exist.

at vendor\laravel\framework\src\Illuminate\Container\Container.php:1019
1015▕
1016▕ try {
1017▕ $reflector = new ReflectionClass($concrete);
1018▕ } catch (ReflectionException $e) {
➜ 1019▕ throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
1020▕ }
1021▕
1022▕ // If the type is not instantiable, the developer is attempting to resolve
1023▕ // an abstract type such as an Interface or Abstract Class and there is

1 vendor\laravel\framework\src\Illuminate\Container\Container.php:1017
ReflectionException::("Class "DatabaseSeeder" does not exist")

2 vendor\laravel\framework\src\Illuminate\Container\Container.php:1017
ReflectionClass::__construct("DatabaseSeeder"
can you help me to solve my error?

limber matrix
thick bison
#

this is my migration,models,and seeder code
Migration User Tables

            $table->id();
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('photo')->nullable();
            $table->string('address')->nullable();
            $table->string('password');
            $table->string('gender')->nullable();
            $table->enum('role', ['admin', 'user'])->default('user');
            $table->timestamps();
        }); ```
Models
``` protected $fillable = [
        'name',
        'email',
        'photo',
        'address',
        'password',
        'gender',
        'role',
        'google_id',
    ];```
Seeder
```public function run(): void
    {
        

        User::create([
            'name' => 'admin',
            'email' => 'xxxxxxxxxx', (Hide the email)
            'password' => bcrypt('admin'),
            'role' => 'admin',
        ]);
        User::create([
            'name' => 'user',
            'email' => 'xxxxxxxxx', (Hide the )
            'password' => bcrypt('user'),
            'role' => 'user',
        ]);
    } ```
limber matrix
#

ok?

thick bison
#

and i got this in my command terminal like
Illuminate\Contracts\Container\BindingResolutionException

Target class [DatabaseSeeder] does not exist.

at vendor\laravel\framework\src\Illuminate\Container\Container.php:1019
1015▕
1016▕ try {
1017▕ $reflector = new ReflectionClass($concrete);
1018▕ } catch (ReflectionException $e) {
➜ 1019▕ throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
1020▕ }
1021▕
1022▕ // If the type is not instantiable, the developer is attempting to resolve
1023▕ // an abstract type such as an Interface or Abstract Class and there is

1 vendor\laravel\framework\src\Illuminate\Container\Container.php:1017
ReflectionException::("Class "DatabaseSeeder" does not exist")

2 vendor\laravel\framework\src\Illuminate\Container\Container.php:1017
ReflectionClass::__construct("DatabaseSeeder"

limber matrix
#

Yeah that's what your post started with. To which I replied.

lucid sonnet
#

Double check the seeder namespace? I usually get this error when I mistype that.

limber matrix
thick bison
limber matrix
#

What exactly do you mean by "followed your way"? Did you check if the class exists, does it have the correct namespace, does it have the correct filename etc?
Maybe share some more details

sick glen
#

First of all

#

The composer.json load the database folder?

#

😀

cosmic atlas
#

I think --seed always runs DatabaseSeeder by default and you must have deleted it. I use that seeder to orchestrate all my other seeders