Create your form with name prefixes for each field. Like student_email, partner_email, etc. When you do validation you can validate them correctly.
Mar 10, 2018
3
Level 9
Single request, multiple models of the same type
I have a situation where user needs to fill one form that has student and partner information. I have to validate both at the same time and display errors - it's the same model that's duplicated.
Here is an example for the data I receive.
I have a RegisterRequest that looks like this,
public function rules() {
return [
'Email' => 'required|string|email|max:100|unique:students,Email',
'Password' => 'required|string|min:4|confirmed',
'FirstName' => 'required|string|max:100',
'LastName' => 'required|string|max:100',
'PhoneHome' => 'required|string|max:100',
'PhoneCell' => 'string|max:100',
'MaleFemale' => 'required|string|max:100',
'Street' => 'required|string|max:100',
'Apt' => 'string|max:100',
'City' => 'required|string|max:100',
'Postal' => 'required|string|max:100',
'Date' => 'required|string|max:100',
];
}
Please or to participate in this conversation.