Skip to content
Advertisement

SQLSTATE[23000]: Integrity constraint violation: 1048 laravel 5.7

I am getting error in Laravel 5.7:

IlluminateDatabaseQueryException SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘name’ cannot be null (SQL: insert into stores (name, matric, phone, email, password, updated_at, created_at) values (?, ?, ?, ?, ?, 2019-10-01 16:29:49, 2019-10-01 16:29:49))

This is my form:

JavaScript

This is UserController:

JavaScript

This is the Migration:

JavaScript

Advertisement

Answer

You are missing name attribute in your html form. Without this attribute your input data won’t be passed to the controller and thus you are getting empty values. So add the name attribute to the input fields.

JavaScript

And also change your validation

JavaScript
Advertisement