Skip to content

Commit 516eb78

Browse files
authored
Merge pull request yajra#41 from gredimano/response-only
Create docs for only column response.
2 parents 7bec936 + 8261d4a commit 516eb78

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

documentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- [Fractal Transformer](/docs/{{package}}/{{version}}/response-fractal)
3232
- [Fractal Serializer](/docs/{{package}}/{{version}}/response-fractal-serializer)
3333
- [Additional Data Response](/docs/{{package}}/{{version}}/response-with)
34+
- [Only Columns](/docs/{{package}}/{{version}}/response-only)
3435

3536
- ## Column Editing
3637
- [Add Column](/docs/{{package}}/{{version}}/add-column)

response-only.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Only Response
2+
3+
Get only selected columns in response.
4+
5+
```php
6+
use DataTables;
7+
8+
Route::get('user-data', function() {
9+
$model = App\User::query();
10+
11+
return DataTables::eloquent($model)
12+
->only(['id','name'])
13+
->toJson();
14+
});
15+
```
16+
17+
<a name="response"></a>
18+
## Example Response
19+
20+
```json
21+
{
22+
"draw": 2,
23+
"recordsTotal": 10,
24+
"recordsFiltered": 2,
25+
"data": [{
26+
"id": 476,
27+
"name": "Esmeralda Kulas"
28+
}, {
29+
"id": 6,
30+
"name": "Zachery Muller"
31+
}]
32+
}
33+
```

0 commit comments

Comments
 (0)