0

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>
                                    </span>
                                @endif
                            </div>
                        </div>

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?

3
  • no any sujjection here Commented Dec 27, 2017 at 17:25
  • 2
    Is nic set to fillable in your user class? Commented Dec 27, 2017 at 17:26
  • yes now it is working Commented Dec 27, 2017 at 17:30

1 Answer 1

1

Check in your User model if nic is added in $fillable array because you do a 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'];

}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.