Illuminate \ Database \ QueryException (HY000) SQLSTATE[HY000]: General error: 1364 Field 'verifyToten' doesn't have a default value
Illuminate \ Database \ QueryException (HY000) SQLSTATE[HY000]: General error: 1364 Field 'verifyToten' doesn't have a default value
我想创建一个验证令牌并将其存储在数据库中,以便在注册后激活用户帐户。但我收到上述错误。
你能帮忙吗
用户Table
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),
]);
在您的用户迁移中,您的字段名称是 $table->string('verifyToten');
,而在您的注册控制器中,您正在保存 'verify_token' => Str::random(40)
的值,在您的控制器中将 verify_token
更改为 verifyToten
我想创建一个验证令牌并将其存储在数据库中,以便在注册后激活用户帐户。但我收到上述错误。 你能帮忙吗
用户Table
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),
]);
在您的用户迁移中,您的字段名称是 $table->string('verifyToten');
,而在您的注册控制器中,您正在保存 'verify_token' => Str::random(40)
的值,在您的控制器中将 verify_token
更改为 verifyToten