我已经在用户的桌上摆满每个必填字段,但仍然收到这个错误:
SQLSTATE[HY000]: General error: 1364 Field 'profession' doesn't have a default value (SQL: insert into `users` (`name`, `email`, `password`, `updated_at`, `created_at`) values (Tushar Saha, [email protected], $2y$10$LDoHlFMH6irkn4riSaAA6evH.BxBw77HBKtluIAAn/gE2R9OmXfKy, 2019-02-08 13:13:25, 2019-02-08 13:13:25))
参数:
"SQLSTATE[HY000]: General error: 1364 Field 'profession' doesn't have a default value (SQL: insert into `users` (`name`, `email`, `password`, `updated_at`, `created_at`) values (Tushar Saha, [email protected], $2y$10$LDoHlFMH6irkn4riSaAA6evH.BxBw77HBKtluIAAn/gE2R9OmXfKy, 2019-02-08 13:13:25, 2019-02-08 13:13:25))
我有双重检查的行业拼写
我还要检查在网络部分的贴值:
_token
"D9UB2NCdncIsorcsqmJGiy2QJZq0D5YSirnbBz5W"
name "Tushar Saha"
profession "Student"
email "[email protected]"
password "111111"
password_confirmation "111111"
RegisterController.php
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'profession' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:6', 'confirmed'],
]);
}
在迁移:
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('profession');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->tinyInteger('role')->default('3');
$table->rememberToken();
$table->timestamps();
});
}
鉴于
<div class="form-group row">
<label for="profession" class="col-md-4 col-form-label text-md-right">{{ __('Profession') }}</label>
<div class="col-md-6">
<select name="profession" class="form-control{{ $errors->has('profession') ? ' is-invalid' : '' }}" value="{{ old('profession') }}" required autofocus>
<option value="">Select One</option>
<option value="Student">Student</option>
<option value="Employed">Employed</option>
<option value="Business Man">Business Man</option>
</select>
@if ($errors->has('profession'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('profession') }}</strong>
</span>
@endif
</div>
</div>
我在想什么?
我要去无路可退,并帮助你,你似乎不被响应的人:
之一:
“专业”是在你protected $fillable
型号搜索User
丢失,它应该是这样的:
class CmsUser extends Authenticatable
{
protected $fillable = [
'name', 'email', 'profession', 'password',
...
}
或者,你的控制器是不正确的,缺少像
$user->profession = $request('profession')
请提供更多资讯