I am using Laravel 5.2 and want to update user's account using validator.
I want to keep email field unique, but, if the user type his current email it will break. How can I update if the email is unique, except the user's own current email?
Laravel includes a wide variety of convenient validation rules that you may apply to data, even providing the ability to validate if values are unique in a given database table.
The easiest and safest way to check whether an email address is well-formed is to use PHP's filter_var() function.
You can tell that to validators:
'email' => 'unique:users,email_address,'.$user->id
Check the docs, in section 'Forcing A Unique Rule To Ignore A Given ID'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With