vendredi 22 juin 2018

Add Form Data to Laravel Auth Registration

Hey guys i am new to laravel and i am trying to add a column 'role' into the existing laravel auth registration.But whenever i click register it gave me an ErrorException(E_NOTICE) Undefined index:role .It was pointing at the 'role' in the creation function. Anyone can point out what am i missing?

I have created a migration and made the migration and added these in the up() function

public function up()
{
    Schema::table('users', function (Blueprint $table) {
        $table->string('role');
    });
}

Then i updated the $fillable array in User.php like this

protected $fillable = [
    'name', 'email', 'password', 'role'
];

Next i added the field in the create function in RegisterController as shown

protected function create(array $data)
{
    return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'password' => Hash::make($data['password']),
        'role' => $data['role'],
    ]);
}

Lastly i added the role register.blade.php

<div class="form-group row mb-0">
    <div class="col-md-6 offset-md-4">
        <button type="submit" class="btn btn-primary">
            
        </button>
    </div>
</div>

What am i missing?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire