Datatables Package for Laravel 5 with Parse as data source

Deadly 提交于 2019-12-10 11:53:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!