Two or One required filed in Laravel validation
I want to pass one out of two or two of them will be passed. But if none of them are filed then nothing will be happened to give me errors.
$validator = Validator::make($request->all(), [
'mobile_number' => 'required_without:phone_number|nullable',
'phone_number' => 'required_without:mobile_number|nullable',
]);
if ($validator->fails()) {
return redirect()->back()->with('error', $validator->errors()->first());
}