2017-12-27 770 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']; 

} 
相關問題