I need to delve into the validation of a single field in Laravel , in my case with email .
I know the following functionality should work in Laravel
'email' => 'unique:App\User,email',
But this functionality in the Livewire form does not work in real time. When I get to submit, if the email is repeated, it gives me the following error:
laravel Integrity constraint violation: 1062 Duplicate entry email unique
I do not know the functionality of it, I assumed that this avoided the error and validated that the mail is unique in the form. This is not the case, would I be missing something?
Or should I do the rule manually?
$usuario = User::where('email', $email);
I really appreciate your time spent on my consultation.
Analyzing the Livewire validation I found a cool method in real time.
https://laravel-livewire.com/docs/input-validation
Well not if it's a little late but hopefully it will help someone.
For when a record is created and you want it to be unique I do it like this
and use this for realtime validation
to do the validation when updating a single record you can do it in the following way depending on how you have in the $rules
In my case I do it like this since I handle different controllers both to create and to update
And to activate the validation in real time the following is added