Chumper / Datatable

This is a laravel 4 package for the server and client side of datatables at http://datatables.net/
https://github.com/Chumper/Datatable
388 stars 154 forks source link

Integrating with Guzzle (external Rest API) #310

Open panelo opened 9 years ago

panelo commented 9 years ago

Hi, I was wondering if there's a way to integrate this with guzzle? I'm calling an external restful api. I'm new to Datatable so not sure if it's possible. Right now i'm just doing a foreach in my view. How to integrate this with datatable?

Controller

public function getIndex() {
    $client = new \GuzzleHttp\Client();
    $response = $client->get('http://api.company.com/members');
    $body = json_decode($response->getBody());
    $content = view('members')->with('members',$body);
    return Admin::view($content, 'Members');
}

View

@foreach ($members as $member)
    <tr>
        <td>{{ $member->name }}</td>
        <td>{{ $member->email }}</td>
        <td>{{ $member->phone }}</td>
    </tr>
@endforeach