Laravel validation exists where NOT

后端 未结 6 1908
温柔的废话
温柔的废话 2021-02-04 04:58

Based on the documentations. Exists can have 4 parameters:

exists:table,id,where,0

The question is, What if I wanted it to be where is not. Lik

6条回答
  •  天命终不由人
    2021-02-04 05:42

    With Laravel 5.2 or later you can prepend the values to be checked against with a !:

    'groups' => 'required|exists:groups,jid,parent,!0'
    

    The same login goes for unique, only you need the extra parameters:

    'groups' => 'required|unique:groups,jid,NULL,id,parent,!0'
    

提交回复
热议问题