I want to display on page some data from api call. The data is for bitcoin payments. So I have orders and if customer pay with bitcoins I want to see confirmations, amount etc.
Here is one example url which return json data.
Here is what I'm trying in my controller
public function ordersView($orderId) {
/** @var Order $order */
$order = Order::where('order_id', $orderId)->first();
if (!$order) {
App::abort(404);
}
$url="http://btc.blockr.io/api/v1/tx/info/9585d5f635eddf737c8351bfe0879c3dbef3d94de9feda2bd74c990b06b7dc52";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
$result=curl_exec($ch);
curl_close($ch);
$total = file_get_contents($url);
return View::make('site.admin.orders_view', [
'order' => $order,
'total' => $total
]);
}
And then on the view
@foreach($order->getOrderData($order->data) as $itemId => $item)
// some product info like name, description etc..
@foreach($total as $i => $totals)
{{ $totals['confirmations'] }}
{{ $totals['time_utc'] }}
@endforeach
@endforeach
Current error which I get is
'Invalid argument supplied for foreach()
On the inner foreach
@foreach($total as $i => $totals)
{{ $totals['confirmations'] }}
{{ $totals['time_utc'] }}
@endforeach
Can someone help me how exactly I can parse this data?