markese/datatables

创建与 Datatables 兼容的 HTTP 响应,用于从 Eloquent 模型、查询构建器和 Laravel 集合。

1.0.1 2017-03-21 00:18 UTC

This package is not auto-updated.

Last update: 2024-09-18 21:21:25 UTC


README

Software License

Laravel 的一个包,将 Eloquent 查询和 Illuminate 集合集成到 JQuery Datatables 中。

结构

src/

安装

通过 Composer

$ composer require markese/datatables

用法

// Laravel:
namespace App\Http\Controllers;
use  Markese\Datatables\Datatables;

class Controller extends BaseController
{
    public function datatablesExample (Request $request)
    {
        $users = Users::query();
        return Datatables::response($users, $request);
    }
}
// Datatables:
$('#example').DataTable( {
    "serverSide": true,
    "processing": true,
    "ajax": "datatablesexample",
    columns : [
        // The "name" property in the column initialization for Model attributes are optional.

        // This works...
        { "data": "id", "title": "Id" },

        // And so does this...
        { "data": "name", "title": "Name", "name": "name" },
        { "data": "email", "title": "Number", "name": "email" },

        // The "name" properties in your Datatables column initialization
        // will eager load the relations of the Model you are querying against 
        // when you use Laravel dot notation...
        { "data": "groups[].name", "title": "Groups", "name": "groups.*.name" },

        // The "data" properties in the column initialization represent the displayed data
        // which is accessible using standard JavaScript bracket notation...
        { "data": "groups[].roles[].title", "title": "Roles", "name": "groups.*.roles.*.title" }
    ]
} );

变更日志

有关最近更改的更多信息,请参阅 CHANGELOG

贡献

有关详细信息,请参阅 CONTRIBUTINGCONDUCT

安全

如果您发现任何与安全相关的问题,请通过电子邮件 john.markese@gmail.com 反馈,而不是使用问题跟踪器。

鸣谢

许可

MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件