【问题标题】:Laravel: seeding errorLaravel:播种错误
【发布时间】:2015-06-29 14:07:06
【问题描述】:

我正在尝试为用户表播种,但出现以下错误: [反射异常] 类 UsersTableSeeder 不存在

我不知道出了什么问题,我用其他桌子和播种机多次这样做。

这是我的迁移

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',
        ]);
    }
}

...

感谢大家的帮助。

【问题讨论】:

    标签: laravel faker


    【解决方案1】:

    请运行composer dump-autoload 并再试一次

    【讨论】:

      猜你喜欢
      • 2014-11-26
      • 2014-07-28
      • 1970-01-01
      • 2017-08-02
      • 2017-07-21
      • 1970-01-01
      • 2014-08-26
      • 2014-12-08
      • 2014-08-14
      相关资源
      最近更新 更多