php artisan migrate:fresh --seed
Dropped all tables successfully.
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table (388.12ms)
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated: 2014_10_12_100000_create_password_resets_table (664.45ms)
Migrating: 2014_10_12_200000_add_two_factor_columns_to_users_table
Migrated: 2014_10_12_200000_add_two_factor_columns_to_users_table (125.81ms)
Migrating: 2019_08_19_000000_create_failed_jobs_table
Migrated: 2019_08_19_000000_create_failed_jobs_table (456.85ms)
Migrating: 2019_12_14_000001_create_personal_access_tokens_table
Migrated: 2019_12_14_000001_create_personal_access_tokens_table (1,087.48ms)
Migrating: 2021_06_07_082644_create_sessions_table
Migrated: 2021_06_07_082644_create_sessions_table (2,139.29ms)
Illuminate\Contracts\Container\BindingResolutionException
Target class [Database\Seeders\UsersTableSeeder] does not exist.
at vendor\laravel\framework\src\Illuminate\Container\Container.php:879
875▕
876▕ try {
877▕ $reflector = new ReflectionClass($concrete);
1 D:\vendor\laravel\framework\src\Illuminate\Container\Container.php:877
ReflectionException::("Class "Database\Seeders\UsersTableSeeder" does not exist")
2 D:\vendor\laravel\framework\src\Illuminate\Container\Container.php:877
-kelompok-7\vendor\laravel\framework\src\Illuminate\Container\Util.php:40
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
UserTableSeeder.php
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class UserTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
User::factory()->create([
'name' => 'Admin',
'email' => '[email protected]',
'password' => bcrypt('password');
'type' => User::ADMIN,
]);
User::factory()->count(5)->create();
}
}
What should i do to fix Class "Database\Seeders\User" not found ? I already triedmigrate fresh and db:seed but its not working. how can i make the User working? I need some help. I need to make it long because i keep getting an "It looks like your post is mostly code; please add some more details."
CodePudding user response:
The error because There's no Class called 'UsersTableSeeder' , and The Class Name is 'UserTableSeeder' - without 'S' . so check the DatabaseSeeder.php in Database\Seeders and modify it and run the command again , it will work .
CodePudding user response:
In the DatabaseSeeder.php change what you have in the run()
from
public function run()
{
$this->call([
UsersTableSeeder::class,
]);
}
to
public function run()
{
$this->call([
UserTableSeeder::class,
]);
}