Answer the question
In order to leave comments, you need to log in
Laravel how to make many records in 1 table with 1 controller request?
Hello! I will be very grateful for your help.
There is an array of objects on the client, I make an ajax post request to the server and I get an error:
Error: Request failed with status code 500
This is how the method to which the route leads
public function setDataCalendar(Request $request)
{
foreach ($request as $dec) {
DecisionTask: :create([
'hours' => $dec->hours,
'date' => $dec->date,
'id_task' => $dec->task_id
]);
}
}
all passed data is correct.
when transferring the 1st object, I removed foreach and changed $dec to $request and the REQUEST WORKED.
What is the problem, who knows?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question