照亮\数据库\ QueryException(HY000)SQLSTATE [HY000]:常规错误:1364字段“ verifyToten”没有默认值

时间:2018-10-19 10:43:51

标签: mysql email-verification laravel-5.7

我想在注册后创建一个验证令牌并将其存储在数据库中以激活用户的帐户。但是我遇到了以上错误。 你能帮忙吗?

用户表

       Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->string('phone',10)->unique();
        $table->string('password');
        $table->string('verifyToten');
        $table->boolean('is_active')->default(0);
        $table->timestamp('email_verified_at')->nullable();
        $table->rememberToken();
        $table->timestamps();
    });

用户模型

   protected $fillable = [
    'name', 'email', 'phone', 'password','verifyToten'
];

注册控制器

        return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'phone' => $data['phone'],
        'password' => bcrypt($data['password']),
        'verify_token' => Str::random(40),
    ]);

1 个答案:

答案 0 :(得分:0)

在用户迁移中,您的字段名称为$table->string('verifyToten');,而在注册控制器中,您正在为'verify_token' => Str::random(40)保存值,将控制器中的verify_token更改为verifyToten