There is a controller method:
public function addEducation(AddPatientEducationRequest $request) {
dd($request->all());
$state = UserEducation::create($request->validated());
}
The dd() returns me an array that I need to insert into db:
array:1 [ // appHttpControllersApiPatientController.php:99
"education" => array:1 [
0 => array:5 [
"patient_id" => 1
"education_id" => 2
"diplom" => "ZV 800"
"start_date" => "2021-10-30"
"end_date" => "2022-10-30"
]
]
]
I tried this way using loop:
foreach($request->education as $value) { UserEducation::create($value); }
2
Answers
Your content looks like this:
So, you can reach your record like this:
, hence your script should be
If
education
multidimensional array matches database columns then you can use the insert method like belowRef :Insert Statements