title: access data array in JSON with Laravel & Guzzle
body: <p>I'm trying to retrieve data from an API that gives a response like so:</p>
  
  <pre><code>{
     "data":[
        {
           "first_name":"John",
           "last_name":"Smith",
           "group":"3",
           "email":"jsmith@talktalk.net"
        },
        {
           "first_name":"John",
           "last_name":"Doe",
           "group":"3",
           "email":"johndoe@aol.com"
        }
     ],
     "meta":{
        "pagination":{
           "total":2,
           "count":2,
           "per_page":500,
           "current_page":1,
           "total_pages":1,
           "links":[
  
           ]
        }
     }
  }
  </code></pre>
  
  <p>I'm trying to use Guzzle to import into my Laravel app</p>
  
  <pre><code>$client = new \GuzzleHttp\Client();
        $response = $client-&gt;request('GET', 'http://localhost/members.json');
        $data = (string) $response-&gt;getBody();
  </code></pre>
  
  <p>and then a foreach to loop over each record and then add it to the database. Right now though I'm struggling to drill down into a record.</p>
  
  <p>What am I missing?</p>
  
  <p>EDIT: Here's the foreach</p>
  
  <pre><code>foreach ($data['data'] as $person) {
          Contact::create(array(
            'name' =&gt; $person-&gt;first_name,
          ));
        }
  </code></pre>