File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ # Add Columns
2+
3+ Add mutated / hidden columns.
4+
5+ <a name =" blade " ></a >
6+ ## Add hidden model columns
7+
8+ ``` php
9+ use DataTables;
10+
11+ Route::get('user-data', function() {
12+ $model = App\User::query();
13+
14+ return DataTables::eloquent($model)
15+ ->addColumns(['foo','bar','buzz'=>"red"])
16+ ->toJson();
17+ });
18+ ```
19+
20+ <a name =" response " ></a >
21+ ## Example Response
22+
23+ ``` json
24+ {
25+ "draw" : 2 ,
26+ "recordsTotal" : 10 ,
27+ "recordsFiltered" : 3 ,
28+ "data" : [{
29+ "id" : 476 ,
30+ "name" : " Esmeralda Kulas" ,
31+ "email" : " abbott.cali@heaney.info" ,
32+ "created_at" : " 2016-07-31 23:26:14" ,
33+ "updated_at" : " 2016-07-31 23:26:14" ,
34+ "deleted_at" : null ,
35+ "superior_id" : 0 ,
36+ "foo" :" value" ,
37+ "bar" :" value" ,
38+ "buzz" :" red"
39+ }, {
40+ "id" : 6 ,
41+ "name" : " Zachery Muller" ,
42+ "email" : " abdullah.koelpin@yahoo.com" ,
43+ "created_at" : " 2016-07-31 23:25:43" ,
44+ "updated_at" : " 2016-07-31 23:25:43" ,
45+ "deleted_at" : null ,
46+ "superior_id" : 1 ,
47+ "foo" :" value" ,
48+ "bar" :" value" ,
49+ "buzz" :" red"
50+ }]
51+ }
52+ ```
You can’t perform that action at this time.
0 commit comments