Passing batch request results to Laravel view

60 views
Skip to first unread message

Tyler Clair

unread,
Jun 9, 2014, 12:31:06 AM6/9/14
to guz...@googlegroups.com
I have been trying to get this batch request to return both sets of results to a Laravel view so I can use them but when I run this the last set of results is the only one returned. I am fairly new to Guzzle and Laravel and from the docs I know that it returns a SplObjectStorage but I do not understand how to manipulate it to be able to send it to the view.

      $result = array();
      $requests = [
      $client->createRequest('GET', 'courses/' . $course_id, ['headers' => ['Authorization' => 'Bearer '. $token]]),
      $client->createRequest('GET', 'courses/' . $course_id . '/sections?per_page=50', ['headers' => ['Authorization' => 'Bearer '. $token]]),
        ];
    $results = \GuzzleHttp\batch($client, $requests);
    foreach ($results as $request) {
    $result = $results[$request];
    }
    $data = $result->json();
    return View::make('courses.results')->with('data', $data);

Thanks,
Tyler Clair
Reply all
Reply to author
Forward
0 new messages