Laravel 5 Validation unique pass variable placeholder

前端 未结 4 1849
时光说笑
时光说笑 2021-02-09 20:42

Is it possible to pass the unique validation method extra where clauses with a variable?

Heres an example:

In my model I have my validation rules.



        
4条回答
  •  逝去的感伤
    2021-02-09 21:35

    in Laravel 5, your "public function rules()" is supposed to be in your FormRequest object:

     'required|unique:table,column,user_id,' . $this->input('field-or-whatever-you-need-from-request'),
           ];
        }
    }
    ?>
    

提交回复
热议问题