php - Laravel - BadMethodCallException: Method IlluminateValidationValidator::validatePatternName does not exist

the value in patternName field is stored in pattern_name column of course_patterns table. When i added unique validation for this field, am getting the error BadMethodCallException: Method Illuminate\Validation\Validator::validatePatternName does not exist in file C:\wamp64\www\Laravel\projects\abcd\vendor\laravel\framework\src\Illuminate\Validation\Validator.php on line 1509. otherwise, evrything works fine. As the soft deleted rows are not counted for unique validation, i added below code,which works fine for me another project.How can i fix this?

 public function update(Request $request, $id){
    $validator=Validator::make($request->all(),
        [
          'patternName'=>['required','string','pattern_name',Rule::unique('course_patterns')->where('function($query){
            return $query->whereNull('deleted_at');
          })->ignore($id)],
         'file'=>'nullable|image',
         'contentTypeId'=>'nullable|integer'
       ]);
 }

Answer

Solution:

By default, the Unique rule will check the uniqueness of the column matching the the attribute being validated.But, you can pass a second argument if the name is different

public function update(Request $request, $id){
    $validator=Validator::make($request->all(),
        [
          'patternName'=>['required','string',Rule::unique('course_patterns','pattern_name')->where('function($query){
            return $query->whereNull('deleted_at');
          })->ignore($id)],
         'file'=>'nullable|image',
         'contentTypeId'=>'nullable|integer'
       ]);
 }

Source