叫我傻,但我无法得到它:) 我想设置验证器规则,因此只有在存在两个字段之一(adgroup或all_adgroups)时它才会通过。
这是我的控制器:
<?php
class Welcome extends CI_Controller {
public function __construct()
{
$this->load->model('perfect_mdl');
$this->email = $this->session->userdata('email');
$this->data['details'] = $this->Perfect_mdl->get_login_user_detail($email);
}
}
这是dd:
$this->validate($request,
[
'new_target_cpa_value' => 'required|numeric',
'adgroups' => 'exists:google.ad_groups,id|required_without_all:all_agroups',
'all_agroups' => 'required_without_all:adgroups'
]
);
dd($request->all());
答案 0 :(得分:3)
试试这个:
$this->validate($request,
[
'new_target_cpa_value' => 'required|numeric',
'adgroups' => 'exists:google.ad_groups,id',
'all_agroups' => 'required_unless:adgroups,null'
]
);