jeudi 29 juillet 2021

Create array in laravel passing vuejs?

$arrList = [];
foreach ($product as $val) {
    $arrList[]['name'] = $val->name;
    $arrList[]['quantity'] = $val->quantity;
}

return response()->json($arrList);

I am a PHP newbie, so I'm not sure how to handle this. I want the name and quantity to be in the same array.

To the Vue side get the same result?

(2) [{…}, {…}, {…}, {…}, {…}, {…}, __ob__: Observer]
0:
name: iphone
quantity: 100
1:
name: samsung
quantity: 130


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire