我想知道是否确实可以“你需要提供电话号码或电子邮件地址。”
目前我的要求是
public function rules()
{
return [
'first_name' => 'required|min:3',
'email_address' => 'required|email',
'phone' => 'required',
'body' => 'required|min:3',
];
}
我会用if语句吗?
答案 0 :(得分:1)
您可以使用required_without
规则:https://laravel.com/docs/5.3/validation#rule-required-without
public function rules()
{
return [
'first_name' => 'required|min:3',
'email_address' => 'required_without:phone|email',
'phone' => 'required_without:email_adress',
'body' => 'required|min:3',
];
}
顺便说一句,我非常确定有些人有2个字母的名字。