I am in a trouble with API development with Laravel 5.3.
My application is a shopping app, after verify the cart need to submit the cart details and customer details to server through an API.
Android PostData in LogCat
{"customer_id":378,"customer_shipping_id":487,"order_amount":13.5,"cashback":0,"store_id":134,"delivery_amount":0.0,"currency":133,"coupon":"","product_array":"[\"{\\\"product_id\\\":933,\\\"product_quantity\\\":1,\\\"product_name\\\":\\\"7up Cherry 330ml\\\",\\\"total\\\":3.5}\",\"{\\\"product_id\\\":722,\\\"product_quantity\\\":1,\\\"product_name\\\":\\\"A&W Root Beer Aged Vanilla 355ml\\\",\\\"total\\\":10.0}\"]"}
Laravel Controller
$customer_id = Input::get('customer_id');
$shipping_id = Input::get('customer_shipping_id');
$amount = Input::get('order_amount');
$cashback = Input::get('cashback');
$store_id = Input::get('store_id');
$delivery_charge = Input::get('delivery_amount');
$coupon = Input::get('coupon');
$currency_id = Input::get('currency');
$product_array = json_decode(Input::get('product_array'));
foreach ($product_array as $item) {
$res[]= $item['product_id'];
}
$response= [
'status' => 200,
'result' => [
'product_ids' => $res
]
];
return $response;
I can get all keys except product_array and not able to loop with the foreach.
var_dump(Input::get('product_array'));