samedi 21 août 2021

How to post lots of data to laravel database

please i am trying to submit this data to a database in laravel...i want to submit all same time, this is just two rows but i want even if it gets to 10 rows i can submit.

0: {item: "Electronics", subitem: "Laptop", subitem2: "Hard D", unit: "Length - meter (m)"}
1: {item: "Electronics", subitem: "Laptop", subitem2: "Hard D", unit: "Length - meter (m)"}

What i have tried

  for ($i = 1; $i < count($request->all()); $i++) {

    $answers[] = [
        'item' => $request->item[$i],
        'subitem' => $request->subitem[$i],
        'subitem2' => $request->subitem2[$i]
    ];

I tried to do a for loop using the above code but its not working..got the below error

count(): Parameter must be an array or an object that implements Countable



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire