I have been developing a web app which collects data from database and print. I am using the Laravel framework. I have shown below the code use. I can display the JSON response directly in the my PHP code, but if I try to iterate through the JSON response I cannot get anything.
Here is how I generate the JSON object using Laravel Facades library:
$worklogs = Response::json($data, $this->getStatusCode(), $headers);
Here is the code I used to pass the data to the PHP page:
return view('index')->with('worklogs', $worklogs);
I can print the collected data from the PHP page using the following code:
{{ $worklogs }}
But if I try to iterate through it using the foreach
loop, an error occurs as shown:
In the PHP page this is how I coded it, but it is not working: