I am new to laravel.
Currently, I'm working on user table CRUD
operations. I've no problems while create, delete and read. I want to update user email column with validation.
When I've made email field as unique
, no problem while creating since it will work perfectly with no duplicate email fields.
Validation:
$this->validate($request,[
'email' => 'required|unique:users'
],
$messages = [
'required' => 'The :attribute field is required.',
'unique' => 'The :attribute must be unique',
]
);
But, While updating the record, if email field is not changed and other changed, validation fails due to unique violation because of email is checked with record it self.
I want uniqueness in email field even if user email is changed.
Can anyone give me some suggestion to get out of this problem ?