Home > OS >  Having error in laravel unique validation
Having error in laravel unique validation

Time:06-22

enter image description here I am updating data and want to ignore the email of the login user so I am using ignore in validation but is not working and is giving an error. as I have created a custom login without using modal.

 function updateemployee(Request $request)
{  
    $val=Session::get('Email');
    
    
    $request->validate([
       
        'Email' => ['required', Rule::unique('employee')->ignore($this->employee)]
    
    ]);

enter image description here

CodePudding user response:

You need use code this way.

function updateemployee(Request $request, $employeeId)
{  
    $val=Session::get('Email');
    
    
    $request->validate([
        'Email' => ['required', Rule::unique('employee')->ignore($employeeId)]
    ]);

CodePudding user response:

$validated = $request->validate([
            'title' => 'required|unique:posts|max:255',
            'body' => 'required',
        ]);
  • Related