General Error : Field doesn’t have a default value in Laravel

This is one of the most common problem, developers face while working with Laravel.

SQLSTATE[HY000]: General error: 1364 Field ‘username’ doesn’t have a default value (SQL: insert into users (name, email, password, updated_at, created_at) values (laravel-nepal,, $2y$10$JMnqvKTSHDnai0/UpDlNG.bT693u5ZyBM4MiFKYsJrPv1obhwyfoq, 2019-08-25 04:29:37, 2019-08-25 04:29:37))

Some of the common reasons to come across this problem are :

  1. We might not be sending the username from our input form ( FormRequest may not have the username key )
  2. Fillable property may not have the username field.

How do we solve the problem ?

First make sure we do have username on our request. Do dd() on the request and if we have the username and still the errors is there then we may not have appended the username field on our $fillable property in our model.

Hope this tips was helpful for you 🙂 Happy coding 🙂

Sharing is caring!

Related Post