0
votes

enter image description here

I am getting an error upon registration. I use laravel 7. SQLSTATE[23000]: Integrity constraint violation: 1452

public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->timestamp('email_verified_at')->nullable();
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();

    });
}
2
role_id does not exist in your user table. - Hedayatullah Sarwary
And what's your quesiton about this? Can you share more details? The given migration does not contain any details about using the registration - Nico Haase

2 Answers

0
votes

I think you have role_id in your User table and if you have role_id in your table use the below inside your migration and if you do not have role_id then remove that field from your registration form.

User Migration File

$table->bigInteger('role_id')->unsigned()->nullable();
$table->foreign('role_id')->references('id')->on('roles');

User Model

protected $fillable = [
    'name',
    'email',
    //---Include role_id here also
    'role_id'
    'password',
];
0
votes

The problem is that the role_id value is either missing or that the role_id column you want the data to insert is not present in your users table