I have an OrderRequest with these rules:
public function rules()
{
return [
//
'surname' => 'required|max:255',
'name' => 'required|max:255',
'city' => 'required|max:255',
'post_office'=>'required|max:255',
];
}
I need to ignore surname and name validation if request has user_id
Currently doing it this way:
if ((Input::has('user_id'))) {
return [
//
'city' => 'required|max:255',
'post_office'=>'required|max:255',
];
}
return [
//
'surname' => 'required|max:255',
'name' => 'required|max:255',
'city' => 'required|max:255',
'post_office'=>'required|max:255',
];
}
But can I do it better way and how?
via Batmannn