问题
I am using Laravel 5, Datatables jQuery plugin and Datatables package for handling the server side requests.
Everything works great if I use Eloquent. The problem is my application needs to get the data from Parse.com using it's PHP SDK. Is there a way to make the Datatables package work if I pass to it's of
method an array that contains the data I need to display?
a working example is:
$users = User::select(['name','email']);
return Datatables::of($users)->make();
what I would need would be:
$users = array(['name' => 'John Doe', 'email' => 'john@email.com'],
['name' => 'Robert Roe', 'email' => 'robert@email.com']);
return Datatables::of($users)->make();
回答1:
As of v5.x of Datatables package, It is now possible to pass a Collection as a data source.
$data = array(['name' => 'John Doe', 'email' => 'john@email.com'],
['name' => 'Robert Roe', 'email' => 'robert@email.com']);
$users = new Collection($data);
return Datatables::of($users)->make();
来源:https://stackoverflow.com/questions/30000555/datatables-package-for-laravel-5-with-parse-as-data-source