I have a form submitting a bunch of data. I seem to have all the values printed when I dd($request). But when I make an actual submission to the database, I get an Illuminate\Database\QueryException that tellsme one of the fields has no default value.
I am using Actions and Custom form Requests:
// This is in my rules() function
return [
'name' => ['required', 'string'],
'email' => ['email', 'nullable', 'unique:patients,email'],
'gender' => ['required'],
'age_type' => ['required'],
'age' => ['required', 'numeric'],
'dob' => ['required'],
'address' => ['required'],
'occupation' => ['required'],
'mobile_number' => ['required'],
'nok_id' => ['required'],
'relation_to_next_of_kin' => ['required'],
'other_relation_to_next_of_kin' => ['required_if:relation_to_next_of_kin,5'],
'referral_point' => ['required'],
'referral_point_details' => ['required_if:referral_point,2,4,5'],
'other_referral_point_details' => ['required_if:referral_point,2,4,5'],
'insurance_scheme' => ['required'],
'insurance_id' => ['required_if:insurance_scheme,1'],
'insurance_number' => ['required_if:insurance_scheme,1'],
'date_recorded' => ['nullable', 'date'],
];
// I use a simple action in my controller's store() function:
CreatePatient::execute($request->validated());
But it tells me the Field relation_to_next_of_kin doesn't have a default value. I don't know what the problem is. When I dump the data, I get the value passed for that field.