找到你要的答案

Q:Datatables Package for Laravel 5 with Parse as data source

Q:数据表包laravel 5解析为数据源

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();

我用laravel 5,数据表的jQuery插件和Datatables处理服务器端的请求包。

如果我善于运用,一切都会很棒。问题是我的应用程序需要从parse.com使用的PHP SDK获取数据。有没有办法如果我通过它的方法的一个数组,包含要显示的数据使数据表包工作吗?

一个工作例子是:

$users = User::select(['name','email']);
return Datatables::of($users)->make();

我需要的是:

$users = array(['name' => 'John Doe', 'email' => 'john@email.com'], 
               ['name' => 'Robert Roe', 'email' => 'robert@email.com']);

return Datatables::of($users)->make();
answer1: 回答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();

作为V5。X数据表包,现在可以通过一个集合作为数据源。

$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();
php  parse.com  datatables  jquery-datatables  laravel-5