我有客户数据的形式,我想检查电话是否存在于数据库中(电话和电话2),甚至检查电话2。如果用户写在两个字段相同的电话不接受。
这里是我验证码:
if($request->customer_id == null) {
unset($rules['customer_id']);
$rules['customer_name'] = 'required';
$rules['customer_address'] = 'required';
$rules['customer_phone'] = 'max:11|required|unique:customers,phone,phone2';
$rules['customer_phone2'] = 'max:11|unique:customers,phone,phone2';
$rules['customer_type'] = 'in:regular,special,jomla';
$mesages['customer_name.required'] = translate('the name is required');
$mesages['customer_address.required'] = translate('the address is required');
$mesages['customer_phone.required'] =translate('the phone is required');
$mesages['customer_phone.max'] =translate('the phone number is not correct');
$mesages['customer_phone.unique'] =translate('the phone number is used');
$mesages['customer_phone2.max'] =translate('the phone number is not correct');
$mesages['customer_phone2.unique'] =translate('the phone number is used');
1条答案
按热度按时间yduiuuwa1#
你可以试试这个
different
规则确保phone和phone2字段包含不同的值。