-1
I am trying to start a project in Aravel and am getting this error while selecting sex when registering
"SQLSTATE[HY000]: General error: 1364 Field 'gender' doesn’t have a default value"
return User::create([
'name' => $data['name'],
'avatar' => $avatar_path,
'gender' => $data['gender'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
If I put the option "Gender" Null in my phpMyAdmin works without errors, however it does not show sex and yes "NULL"
My html:
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">Gender</label>
<div class="col-md-6">
<select name="gender" class="col-md-4 control-label">
<option value="male" name="male">Male</option>
<option value="female" name="female">Female</option>
</select>
@error('gender')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
I forgot to mention that I had already done this, in fact I had no Strict mode and ready, I’m still in error
– Atila Oliveira
Run the following command and post the result:
SELECT @@GLOBAL.sql_mode;
If possible also post the Laravel db configuration– Paulo Victor
Showing 0 - 0 records (1 total, Query took 0.0000 seconds.) is still the same. Migration users is this https://i.ibb.co/Tt1qvmm/migation.png
– Atila Oliveira
What do you mean? You didn’t return anything? try to configure the Laravel as follows: 'Connections' => [ 'mysql' => [ 'Strict' => false, 'modes' => [] ] ]
– Paulo Victor
Here I have array for profile picture of each sex and return. They work correctly, but for this reason 'Gender' has to be NULL in phpmyadmin and 'Gender' is NULL https://i.ibb.co/Lxq7m8x/Return.png
– Atila Oliveira
I got it, the word 'Gender' was missing in Protect fillable
– Atila Oliveira