title: Laravel - convert array into eloquent collection
body: <p>I need to use data from an API.</p>
  
  <p>I create a function:</p>
  
  <pre><code>    public function getItems()
  {
      $client = new \GuzzleHttp\Client();
      $res = $client-&gt;get('https://app.example.com/api/getItems');
  
  $vouchers = json_decode($res-&gt;getBody(), true);
  
  dd($vouchers);
  
  return view('api', compact('vouchers'));
  
  
  }
  </code></pre>
  
  <p>and <code>dd($vouchers)</code> return me:</p>
  
  <p><a href="https://i.stack.imgur.com/uFvc9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uFvc9.png" alt="enter image description here"></a></p>
  
  <p>Now when I try to use $vouchers array with blade engine like:</p>
  
  <pre><code>&lt;body&gt;
                @foreach ($vouchers as $v)
                  &lt;p&gt;{{$v-&gt;name}}&lt;/p&gt;
                @endforeach
            &lt;/body&gt;
  </code></pre>
  
  <p>I got error:</p>
  
  <pre><code>"Trying to get property 'name' of non-object (View: .... etc...
  </code></pre>
  
  <p>How I can convert array into eloquent collection.
  I use the latest Laravel 5.7 version</p>