Unique validation rule not applicable to db index

in my migration file i have applied a unique constraint to the email column of my user model. when trying to addionally apply a frontend validation in the user resource using the unique function, i get no result. thus i am still able to insert duplicat emails resulting in an sql error.

Schema::create('users', function (Blueprint $table) {
  $table->id();
  $table->string('first_name');
  $table->string('last_name');
  $table->string('email')->unique();
  $table->timestamp('email_verified_at')->nullable();
  $table->string('password');
  $table->rememberToken();
  $table->timestamps();
        });

TextInput::make('email')
  ->required()
  ->unique(table: User::class, column: 'email')

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'user@user.com' for key 'users.users_email_unique'
Was this page helpful?