i am new to laravel.. my problem is
i have a html form in which i am taking more than one phone number in a single input text tag using saprator ',' which is working fine.. but when i take that form data to controller i want to validate that each data should be a number and it should be of 10 digit only. same thing i want to do for the email also.
i have use laravel validation for the same but its not working... can anyone please help me on this.. thanx in advance: This is my controller store method code : Controller Code :
public function store(Request $request, Customer $newCustomer)
{
$mobileNo[] = explode(',',$request->contactNo);
$request->contactNo = $mobileNo;
$emails[] = explode(',',$request->email);
$request->email[] = $emails;
Validate::newCustomer($request);
}
Validation code :
public static function newCustomer(Request $request)
{
$request->validate([
'companyName' => 'required|string',
'city' => 'required|string',
'contactNo' => 'required|array',
'contactNo.*' => 'digits_between:10,10',
'email' => 'required|email',
'email.*' => 'email',
]);
}