Newbie to PHP and Laravel 5.2. I created a users table with php artisan make:auth, but want to add two more columns to my database. I was able to add the columns in the database, but when I register new users it accepts everything but first_name and last_name in mysql which come up blank. I don't understand what I'm missing?
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('first_name');
$table->string('last_name');
$table->string('email')->unique();
$table->string('avatar')->default('default.jpg');
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
My AuthController file
protected function validator(array $data)
{
return Validator::make($data, [
'first_name' => 'required|max:255',
'last_name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
]);
}
protected function create(array $data)
{
return User::create([
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
Example of form input for first_name on register.blade
<div class="form-group{{ $errors->has('first_name') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">First Name</label>
<div class="col-md-6">
<input type="text" class="form-control" name="first_name" value="{{ old('first_name') }}">
@if ($errors->has('first_name'))
<span class="help-block">
<strong>{{ $errors->first('first_name') }}</strong>
</span>
@endif
</div>
</div>