ad-mos / laravel-datatables
DataTables Server-Side API for Laravel Framework
Installs: 4 289
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 1
Requires
- php: ^7.1|^8.0
- doctrine/dbal: ^2.6|^3.0
- illuminate/database: ~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10
- illuminate/http: ~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10
README
Quick Installation
$ composer require ad-mos/laravel-datatables
Usage examples
1 - Simple table:
public function data(DataTables $dataTables) { return $dataTables->provide(new User); }
2 - Table with joins:
public function data(DataTables $dataTables) { $model = new User; $query = $model->newQuery() ->leftJoin('user_emails', 'user_emails.user_id', '=', 'users.id') ->leftJoin('user_phones', 'user_phones.user_id', '=', 'users.id') ->groupBy('users.id'); $aliases = [ 'emails' => 'GROUP_CONCAT(DISTINCT `user_emails`.email SEPARATOR \'|\')', 'phones' => 'GROUP_CONCAT(DISTINCT `user_phones`.phone SEPARATOR \'|\')', ]; return $dataTables->provide($this->model, $query, $aliases); }
DataTables can be accessed through IoC, helper or facade:
return $dataTables->provide(...); return datatables()->provide(...); return \DataTables::provide(...);
License
The MIT License. More information here.