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


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3ljmzAS
via IFTTT

تعليقات

المشاركات الشائعة من هذه المدونة

How to Create Treeview with Bootstrap and jQuery

jQuery Datatables with PHP, MySQL and AJAX Example

How to Add Images to Dropdown List using jQuery