Forum Laravel Add an array of data to the database
Hi, I want to add an array consisting of multiple fields to my database. My controller method is :
$Patient_Name = $request->Patient_Name; $Mobile = $request->Mobile; $Surgeon = $request->Surgeon; $Amount = $request->Amount; for($count = 0; $count < count($Patient_Name); $count++) { $data = array( 'Patient_Name' => $Patient_Name[$count], 'Mobile' => $Mobile[$count], 'Surgeon' => $Surgeon[$count], 'Amount' => $Amount[$count] ); $insert_data[] = $data; } hospital_incharge_referred::insert($insert_data);
Not able to pass data to the db. BTW I am passing the values to the controller via ajax.
Please sign in or create an account to participate in this conversation.
There's no shortage of content at Laracasts. In fact, you could watch nonstop for days upon days, and still not see everything!
Get Started
Add an array of data to the database
Hi, I want to add an array consisting of multiple fields to my database. My controller method is :
Not able to pass data to the db. BTW I am passing the values to the controller via ajax.