I just want to achieve a simple task.
My .blade.php file has select box for roles with values
<p>Role:</p>
<div class="form-group">
<select name="role_id" id="role_id">
<option value="1">Admin</option>
<option value="2" selected="selected">User</option>
</select>
</div>
And my request handler is simple:
$user = User::create([
'name' => $request['name'],
'surname' => $request['surname'],
'email' => $request['email'],
'password' => Hash::make($request['password']),
'role_id' => $request['role_id'],
]);
role_id is integer column
But I get error: Field 'role_id' doesn't have a default value.
Like I was not even passing the value? Do I miss something?
What did I try: I tried to google it, but everyone seems to be working with some Laravel selection box, which is just too overwhelming for me at the moment. I want to keep it simple with HTML.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire