Laravel form validation unique using 2 fields

前端 未结 5 1653
渐次进展
渐次进展 2020-12-15 08:09

How can I have a unique validation rule on 2 fields?

a. The application should not allow two people to have the same identical first name and last name.

It i

5条回答
  •  不思量自难忘°
    2020-12-15 08:24

    in my case this works just fine (in controller):

    $request->validate([
        'firstName' => 'required|min:3|max:255|unique:people,firstName,NULL,id,lastname,' . $request->input('lastname'),
    ], [
        'unique' => 'Some message for "unique" error',
    ]);
    

提交回复
热议问题