Laravel: 播种错误
Laravel: seeding error
我正在尝试为用户做种子 table 但我收到以下错误:
[反射异常]
ClassUsersTableSeeder 不存在
我不知道哪里出了问题,我对其他 table 和播种机做了很多次。
这是我的迁移
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('surname');
$table->string('initials');
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
});
}
...
DatabaseSeeder.php
...
$this->call('UsersTableSeeder');
...
UsersTableSeeder.php
use App\User;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Faker\Factory as Faker;
class UsersTableSeeder extends Seeder {
public function run() {
$faker = Faker::create();
User::create([
'name' => 'Some name',
'surname' => 'Some surname',
'initials' => 'SI',
'email' => 'Some email',
'password' => 'Some password',
]);
}
}
...
感谢大家的帮助。
请运行composer dump-autoload
再试一次
我正在尝试为用户做种子 table 但我收到以下错误: [反射异常] ClassUsersTableSeeder 不存在
我不知道哪里出了问题,我对其他 table 和播种机做了很多次。
这是我的迁移
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('surname');
$table->string('initials');
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
});
}
...
DatabaseSeeder.php
...
$this->call('UsersTableSeeder');
...
UsersTableSeeder.php
use App\User;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Faker\Factory as Faker;
class UsersTableSeeder extends Seeder {
public function run() {
$faker = Faker::create();
User::create([
'name' => 'Some name',
'surname' => 'Some surname',
'initials' => 'SI',
'email' => 'Some email',
'password' => 'Some password',
]);
}
}
...
感谢大家的帮助。
请运行composer dump-autoload
再试一次