I need to update an email with a unique role in the Form Request Validation. I have no problem with creating the user, but the problem is when I try to update the email, it shows that the email is already taken. how can I do something like if the email that is in the input value is owned by the user it can be skipped by the unique role.
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
public function rules()
{
return [
'email' => ['sometimes', 'required','email:rfc,dns', 'unique:users,email', 'max:255'],
in controller
public function update(UsersRequest $request, $id)
{
$user = User::find($id);
$user->email = $request->input('email');
$user->save();}
blade code
<input name="email" type="email" class="form-control @error('email') is-invalid @enderror" value="{{ $user->email }}" required>