The third parameter of the unique rule allows you to specify the record identifier to ignore. When you edit a user, you want your unique validation rule to ignore the value contained in the identifier of the user you are editing.
'email'=>'required|email|unique:users,email,'.$userId
You can see the documents in the validation rule here .
The hardest part you'll come across is figuring out how to edit your rule to provide the identifier of the user you are editing. It all depends on how your rules are set and where you perform your check.
source share