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
created_at) values (laravel-nepal, email@example.com, $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 :
- We might not be sending the username from our input form ( FormRequest may not have the username key )
- 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.
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
* The attributes that are mass assignable.
* @var array
protected $fillable = [
'name', 'email', 'password', 'username', // username added
Hope this tips was helpful for you Happy coding