Reputation: 175
Even though I am entering the value of username but whenever i press the submit button this error occurs
And other form fields are working just fine.
$values = array('email' => $request->email,'username' => $request->user_name, 'password' => $request->password);
$test = DB::table('users')->insert($values);
Upvotes: 0
Views: 427
Reputation: 8178
Out of the box, Laravel uses $name
as the fillable field for a user's name. If you are changing this to '$username
' on the User model, make sure you make it fillable:
protected $fillable = [
'username', 'email', 'password',
];
If it isn't fillable on the model, Laravel will return a null value to the database no matter what you fill in. As the DB field username
is probably not nullable in your code, this is likely the source of the error.
Upvotes: 1