most likely the name field does not have any value... please dd($data) in Create method to double check it.
btw, your validator method is not in use in your create method....
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am using the default auth shipped with laravel. When I try to register a user, I get the error MySQL "General error: 1364 Field 'name' doesn't have a default value"
I run the query in workbench and it works. INSERT INTO users (id,name,password,email) values (1,'meteace', '****', 'f***@yahoo.com'); I have used this in a lot of projects just this is giving me problems.
I hope someone catches the problem for me.
Users Migration table
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->BigIncrements('id');
$table->string('name');
$table->string('password');
$table->string('email', 128)->unique();
$table->timestamp('email_verified_at')->nullable();
$table->rememberToken();
$table->timestamps();
});
}
Registers Controller
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
Blade View
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('name') }}</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name"
value="{{ old('name') }}" required autocomplete="name" autofocus>
@error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
Please or to participate in this conversation.