用于Laravel 5的Datatables软件包,以Parse为数据源 [英] Datatables Package for Laravel 5 with Parse as data source

查看:152
本文介绍了用于Laravel 5的Datatables软件包,以Parse为数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Laravel 5, Datatables jQuery插件 Datatables包用于处理服务器端请求。

I am using Laravel 5, Datatables jQuery plugin and Datatables package for handling the server side requests.

如果我使用雄辩,一切都会很好。问题是我的应用程序需要使用其PHP SDK从 Parse.com 获取数据。有没有办法使Datatables包工作,如果我传递方法一个包含我需要显示的数据的数组?

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?

一个工作示例是:

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


推荐答案

Datatables 包,现在可以将Collection作为数据源传递。

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

这篇关于用于Laravel 5的Datatables软件包,以Parse为数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆