Package Data | |
---|---|
Maintainer Username: | imade |
Maintainer Contact: | pieter@imade.nl (Imade) |
Package Create Date: | 2014-08-03 |
Package Last Update: | 2015-05-14 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-11 15:24:58 |
Package Statistics | |
---|---|
Total Downloads: | 126 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
This is a laravel 5 package for the server and client side of datatables at http://datatables.net/
A dedicated class (model) to configure Datatables.net for Laravel to keep your controllers as clean as possible.
##Example
Your Userscontroller:
class UsersController extends \BaseController {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$table = new UserDatatable();
if($table->dataRequest()) return $table->data();
return View::make('resource.index')->withTable($table);
}
}
Dedicated UserDatatable. This class is required to extend "Imade\Datatable\DatatableModel". The two methods "data" and "table" are required.
use Imade\Datatable\DatatableModel;
class UserDatatable extends DatatableModel
{
public $columns = array(
'id' => '#',
'name' => 'Naam',
'email' => 'E-mail'
);
public function data()
{
$query = User::select( array_keys($this->columns) );
return Datatable::query($query)
->showColumns( array_keys($this->columns) )
->make();
}
public function table()
{
return Datatable::table()
->addColumn( array_values($this->columns) );
}
}
##Install
"imade/datatable-model": "dev-master"