我正在尝试从laravel 8登录,但在请求时,我遇到了一个错误,我找不到解决方案。UsersTablesSeeder已创建,但编译器仍无法找到它
Illuminate\Contracts\Container\BindingResolutionException
Target class [UsersTablesSeeder] does not exist.
at C:\xampp\htdocs\pary\vendor\laravel\framework\src\Illuminate\Container\Container.php:832
828▕
829▕ try {
830▕ $reflector = new ReflectionClass($concrete);
831▕ } catch (ReflectionException $e) {
➜ 832▕ throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
833▕ }
834▕
835▕ // If the type is not instantiable, the developer is attempting to resolve
836▕ // an abstract type such as an Interface or Abstract Class and there is
1 C:\xampp\htdocs\pary\vendor\laravel\framework\src\Illuminate\Container\Container.php:830
ReflectionException::("Class "UsersTablesSeeder" does not exist")
2 C:\xampp\htdocs\pary\vendor\laravel\framework\src\Illuminate\Container\Container.php:830
ReflectionClass::__construct("UsersTablesSeeder")下面的代码显示了DatabaseSeeder.php
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Eloquent::unguard();
$this->call(UsersTablesSeeder::class);
}
}这是我的用户表
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use App\User;
class UsersTablesSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
User::create([
'name' => 'John Smith',
'email' => 'john_smith@gmail.com',
'password' => Hash::make('password'),
'remember_token' => str_random(10),
]);
}
}我正在关注这个link
发布于 2021-01-18 22:13:55
将namespace Database\Seeders;添加到您的类。正如laravel 8所说的
种子程序和工厂现在具有名称空间。要适应这些更改,请将Database\Seeders命名空间添加到您的种子类中。此外,应该将以前的数据库/种子目录重命名为数据库/种子:
https://stackoverflow.com/questions/65775841
复制相似问题