Skip to content

A Laravel package to transform Eloquent, Query Builders, and Collections to Datatables for JQuery responses

License

Notifications You must be signed in to change notification settings

jmarkese/Datatables

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A Laravel package to transform Eloquent, Query Builders, and Collections to Datatables for JQuery responses

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages