title: Printing JSON response in PHP using Laravel framework
body: <p>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.</p>
  
  <p>Here is how I generate the JSON object using Laravel Facades library:</p>
  
  <pre><code>  $worklogs = Response::json($data, $this-&gt;getStatusCode(), $headers);
  </code></pre>
  
  <p>Here is the code I used to pass the data to the PHP page:</p>
  
  <pre><code>  return view('index')-&gt;with('worklogs', $worklogs);
  </code></pre>
  
  <p>I can print the collected data from the PHP page using the following code:</p>
  
  <pre><code>  {{ $worklogs }}
  </code></pre>
  
  <p>But if I try to iterate through it using the <code>foreach</code> loop, an error occurs as shown:</p>
  
  <p><img src="https://i.stack.imgur.com/vNL04.jpg" alt="error captured"></p>
  
  <p>In the PHP page this is how I coded it, but it is not working:
  <img src="https://i.stack.imgur.com/CJudm.jpg" alt="captured index.blade.php file portion "></p>