Where to check if email exists....

i'm a bit confused about VALIDATION in my app i need to create a model (technician) associated to the User model (ok) i have the technician email field sets as unique in the db when i create a technician with a non unique email, i need to send a notification now i get an error page with the sql statemnt of duplicated email in the form i have

Forms\Components\TextInput::make('email')
->email()
->required()
->unique()
->maxLength(255),

Forms\Components\TextInput::make('email')
->email()
->required()
->unique()
->maxLength(255),
is not enough?
8 Replies
Soundmit
SoundmitOP9mo ago
also this doesn't works

Forms\Components\TextInput::make('email')
->email()
->required()
->unique(Rule::exists('technicians', 'email'))
->maxLength(255),

Forms\Components\TextInput::make('email')
->email()
->required()
->unique(Rule::exists('technicians', 'email'))
->maxLength(255),
I'm watching some videos, and in all of them, when validation is enabled, a red message appears. I can't seem to do it.
toeknee
toeknee9mo ago
Forms\Components\TextInput::make('email')
->email()
->required()
->unique(ignoreRecord: true)
->maxLength(255),
Forms\Components\TextInput::make('email')
->email()
->required()
->unique(ignoreRecord: true)
->maxLength(255),
Soundmit
SoundmitOP9mo ago
yes, i saw this solution but the problem ssems thah validation is not fired if i have a technician in the db with email [email protected] when i type tec@ i'm expecting a red flag "hey this email already exists"
toeknee
toeknee9mo ago
If that is the case, you will be mounting the form incorrect. Please provide the whole page code.
Soundmit
SoundmitOP9mo ago
ah ok, wait, now it works after i click on the button
Soundmit
SoundmitOP9mo ago
also with the ignoreRecord: true active, i can't update the record
toeknee
toeknee9mo ago
ignoreRecord: true means it ignores this record. Are you sure you don't have duplicated emails in the database already
Want results from more Discord servers?
Add your server