jmarkese / Datatables by jmarkese

Create HTTP responses compatible with Datatables for JQuery from Eloquent Models, Query Builders, and Laravel Collections.
26
5
2
Package Data
Maintainer Username: jmarkese
Maintainer Contact: john.markese@gmail.com (John Markese)
Package Create Date: 2017-03-09
Package Last Update: 2017-08-25
Language: PHP
License: MIT
Last Refreshed: 2024-04-15 15:15:20
Package Statistics
Total Downloads: 26
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 5
Total Watchers: 2
Total Forks: 2
Total Open Issues: 0

Datatables for Laravel

Software License

A package for Laravel that integrates Eloquent queries and Illuminate Collections into Datatables for JQuery.

Structure

src/

Install

Via Composer

$ composer require markese/datatables

Usage

// 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" }
    ]
} );

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email john.markese@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.