为什么Laravel没有保存表单数据?
我在我的laravel应用程序中使用Auth:命令注册表单。我有添加新的网卡输入框register.blade.php文件,因为这, register.blade.php为什么Laravel没有保存表单数据?
<div class="form-group{{ $errors->has('nic') ? ' has-error' : '' }}"> <label for="nic" class="col-md-4 control-label">NIC</label>
<div class="col-md-6">
<input id="nic" type="text" class="form-control" name="nic">
@if ($errors->has('nic'))
<span class="help-block">
<span>{{ $errors->first('nic') }}</span>
</span>
@endif
</div>
</div>
和我AuthController是这样的,
protected function validator(array $data) {
return Validator::make($data, [
'username' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
'nic' => 'required|min:10',
]);
}
protected function create(array $data)
{
return User::create([
'username' => $data['username'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'nic' => $data['nic'],
]);
}
,我有新列在用户表中也有nic。但是当我点击注册按钮时,其他数据值很好地保存在用户表中,但是密码栏没有保存好的值。如何解决这个问题?
回答:
检查您的用户模型。如果NIC在$fillable
阵列添加,因为你做了mass assignement
<?php namespace App;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Backpack\Base\app\Notifications\ResetPasswordNotification as ResetPasswordNotification;
class User extends Authenticatable
{
use Notifiable;
protected $fillable = ['username', 'email', 'password', 'nic'];
}
以上是 为什么Laravel没有保存表单数据? 的全部内容, 来源链接: utcz.com/qa/266552.html