The JSON object array is stored in the products table, need to do a query to retrieve certain objects using Laravel Query Builder. How would I retrieve the first object array, or certain parts of it?
Table : products
Field name : id, prodcatkey normal datatype
Field name : “pricematrix” JSON data type
[
{“packing”:“1”,“size”:“500ml”,“vencode”:“1EIFEL”,“price”:“527.50”},
{“packing”:“3”,“size”:“500ml”,“vencode”:“1EIFEL”,“price”:“1582.50”},
{“packing”:“6”,“size”:“500ml”,“vencode”:“1EIFEL”,“price”:“3165.00”},
{“packing”:“12”,“size”:“500ml”,“vencode”:“1EIFEL”,“price”:“6330.00”}
]
$productall = DB::table('products')
->select('id, 'prodcatkey', 'pricematrix', 'pricematrix->price AS price',
// How could I get the first object array //{“packing”:“1”,“size”:“500ml”,“vencode”:“1EIFEL”,“price”:“527.50”},
)
->orderBy('products.prodcatkey')
->get();
The output
+“pricematrix”: "[{“packing”:“1”,“size”:“750ml”,“vencode”:“YASTUN”,“price”:“536.90”},{“packing”:“3”,“size”:“750ml”,“vencode”:“YASTUN”,“price”:“1610.70”},{“packing”:“6”,“size”:“7 ”
+“price”: null