Skip to content

Commit dd14551

Browse files
authored
Merge pull request yajra#44 from gredimano/add-columns
Add mutated / hidden columns.
2 parents abfd8e2 + 908a44b commit dd14551

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

add-columns.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
```

0 commit comments

Comments
 (0)