i want to save the radio button value to users database. but there is a ERROR:
Undefined index: user_role in RegisterController.php
may i know how to solve this error?
migration:
Schema::table('users',function(Blueprint $table)
{
$table->integer('user_role');
});
Register controller:
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'stuID'=> $data['stuID'],
'user_role'=>$data['user_role'],
]);
}
blade file:
<form class="form-horizontal" role="form" method="POST" action="{{
route('register') }}">
{{ csrf_field() }}
<label for="user_role" class="col-md-4 control-label ">Role</label>
<div class="user_role" id="user_role" data-toggle="buttons">
<label class="btn btn-default user_role">
<input type="radio" name="user_role" id="lecturer" value="1">
<span class="radio-dot"></span>
<span class="user_role-word">Lecturer</span>
</label>
<label class="btn btn-default user_role">
<input type="radio" name="user_role" id="student"value="2">
<span class="radio-dot"></span>
<span class="user_role-word">Student</span>
</label>
</div>