|
| 1 | +<p align="center"> |
| 2 | + <img src="https://github.com/iYogesharma/datatable-laravel/blob/master/logo.png" /></p> |
| 3 | + |
1 | 4 | [](https://packagist.org/packages/iyogesharma/datatable-laravel) |
2 | 5 | [](https://packagist.org/packages/iyogesharma/datatable-laravel) |
3 | 6 | [](https://packagist.org/packages/iyogesharma/datatable-laravel) |
4 | 7 |
|
5 | | -# jQuery Datatables For Laravel 5.x |
| 8 | +# jQuery Datatables For Laravel |
6 | 9 | A simple package to ease datatable.js server side operations |
7 | 10 |
|
8 | 11 | This package is created to handle [server-side](https://www.datatables.net/manual/server-side) and [client-side](https://www.datatables.net/manual) works of [DataTables](http://datatables.net) jQuery Plugin via [AJAX option](https://datatables.net/reference/option/ajax) by using Eloquent ORM, Query Builder or Collection. |
9 | 12 |
|
10 | 13 |
|
11 | | -## datatable-laravel 2.0 |
| 14 | +## datatable-laravel 4.x |
12 | 15 |
|
13 | | -Version 2.0 continues the improvements in version 1.0.3 by introducing some new functions , improved code structure and various bug fixes. |
| 16 | +Version 4.x continues the improvements in version 3.x by introducing some new features |
14 | 17 |
|
15 | 18 | ## New |
16 | 19 |
|
17 | | -Introduced three new functions for the case if you know |
18 | | -query is instance of which class. Currently supported include: |
19 | | -Eloquent Query Builder, Database Query Builder and Eloquent Collection |
20 | | - |
21 | | -```php |
22 | | - |
23 | | - echo datatable()->eloquent(User::query())->init(); |
24 | | - echo datatable()->collection(User::query())->init(); |
25 | | - echo datatable()->queryBuilder(User::query())->init(); |
26 | | - |
27 | | -``` |
| 20 | + - Added support for select raw queries |
| 21 | + |
| 22 | + - Auto guess column names if no columns are provided in request |
| 23 | + |
| 24 | + - Auto guess column names if * is provided in column names |
| 25 | + |
| 26 | + - Added support for group by and havig clause |
| 27 | + |
| 28 | + - Example |
| 29 | + ```php |
| 30 | + echo datatable(User::select('users.name','users.email','users.contact_no','users.role_id') |
| 31 | + ->selectRaw(" |
| 32 | + Max(id) as total |
| 33 | + ") |
| 34 | + ->groupBy('users.name', 'users.email', 'users.contact_no'))->init(); |
| 35 | + |
| 36 | + echo datatable(User::select('users.*'))->init(); |
| 37 | + ``` |
| 38 | + |
| 39 | + |
| 40 | + - Added Support For Data Filtering From Client Side |
| 41 | + - Added Column Wise Search Query Support Using Below Api |
| 42 | + - Example |
| 43 | + ```json |
| 44 | + { |
| 45 | + "columns": [ |
| 46 | + { |
| 47 | + "data": "name", |
| 48 | + "name": "name", |
| 49 | + "searchable": true, |
| 50 | + "orderable": true, |
| 51 | + "search": { |
| 52 | + "value": "", |
| 53 | + "regex": false |
| 54 | + } |
| 55 | + } |
| 56 | + ], |
| 57 | + "start": 0, |
| 58 | + "length": 10, |
| 59 | + "search": { |
| 60 | + "value": "Yoges", |
| 61 | + "regex": false |
| 62 | + }, |
| 63 | + "filters": { |
| 64 | + "role_id" : [1,2],// role id in 1,2 |
| 65 | + "created_at": [date1, date2], // createde at is between date1 and date2, |
| 66 | + "name": "iyogesh" // where name = iyogesh |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + ``` |
28 | 71 |
|
29 | 72 | ## Modified |
30 | 73 |
|
31 | | -Modified make and datatable function . Second parameter here is boolean |
32 | | -with default to false indicate whether you want json response or not. |
33 | | -If you don't pass second parameter then you need to use init() function |
34 | | -as we are using in previous version. |
| 74 | +Modified datatable function to support server side export to xls,csv and json |
35 | 75 |
|
36 | | -```php |
| 76 | +You just need to pass 2 new arguments in query-string/body `export` and ` ext ` |
37 | 77 |
|
38 | | -echo datatable()->make(User::query(),true); |
39 | | -echo datatable(User::query(),true); |
| 78 | +if ` export = true ` it will return download file response |
| 79 | +for `ext` default value is `xlsx` |
40 | 80 |
|
| 81 | +```javascript |
| 82 | + https://datatable-url?export=true&ext=xlsx |
41 | 83 | ``` |
42 | 84 |
|
43 | 85 |
|
| 86 | + |
44 | 87 | ## Using Helper Function |
45 | 88 |
|
46 | 89 | ```php |
|
0 commit comments