如何验证我是否通过电子邮件提升整个个人资料,电子邮件验证工作正常。但是当我更新配置文件而不更改电子邮件时,验证不会让代码运行。请告诉我如何修复电子邮件应该是唯一的,但是当我不更改电子邮件时它也会更新个人资料
$validation_rules['user_id'] = 'required';
$validation_rules['name'] = 'required';
$validation_rules['email'] = 'email|required|unique:users,email';
$validation_rules['phone'] = 'required';
答案 0 :(得分:0)
$validation_rules['user_id'] = 'required';
$validation_rules['name'] = 'required';
$validation_rules['phone'] = 'required';
if (Request::isMethod('put')) {
//which is update
$validation_rules['email'] = 'email|required';
}else{
// if it is not 'put', it is 'post' which is an insert
$validation_rules['email'] = 'email|required|unique:users,email';
}
如果有效,请告诉我