has('nic') ? ' has-error' : '' }}">" />

why did not save form data in Laravel?

php mysql laravel-5

36 观看


38 作者的声誉

I am using Auth: command register form in My laravel application. and I have add new nic input box to register.blade.php file as this, register.blade.php

 <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>

and MY AuthController is like this,

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'],

and I have new column as nic in Users table as well. but when I click register button other data values saving well in users table but nic column not saving nic values. how can solve this problem?

作者: DNK 的来源 发布者: 2017 年 12 月 27 日

回应 (1)


943 作者的声誉


Check in your User model if nic is added in $fillable array because you do a mass assignement


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'];

作者: Goms 发布者: 27.12.2017 05:31