2017-12-27 377 views
0

我在我的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"> 
             <strong>{{ $errors->first('nic') }}</strong> 
            </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。但是当我点击注册按钮时,其他数据值很好地保存在用户表中,但是密码栏没有保存好的值。如何解决这个问题?

+0

这里没有任何 – DNK

+2

是sujjection'nic'在用户级设置为'fillable'? – aynber

+0

是的,现在它正在工作 – DNK

回答

1

检查您的用户模型。如果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']; 

} 
相关问题