Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ap3twe's avatar

General error: 1364 Field 'name' doesn't have a default value

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>
0 likes
5 replies
siangboon's avatar

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....

Ap3twe's avatar

I get all request

array:5 [▼
  "_token" => "gnnThQGv6IshKGb8TYLIv68u8r38Cy674EUdi7Al"
  "name" => "John Doe"
  "email" => "[email protected]"
  "password" => "JohnDoe"
  "password_confirmation" => "JohnDoe"
]
``
Snapey's avatar
Snapey
Best Answer
Level 122

Do you have $fillable in your User model?

XFDev's avatar

Well the code seems fine, couldn't figure out what could cause the issue. It might be related to InnoDB Engine.

Ap3twe's avatar

Jeez for an unknown reason name was missing in the $fillable. Thank you

Please or to participate in this conversation.