File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ # Resource Response
2+
3+ DataTables response using laravel model resource.
4+
5+ ``` php
6+ use DataTables;
7+
8+ $users = App\User::paginate(10);
9+
10+ $resource = App\Http\Resources\UserResource::collection($users);
11+
12+ return DataTables::of($resource)->toJson();
13+ ```
14+
15+ <a name =" response " ></a >
16+ ## Example Response
17+
18+ ``` json
19+ {
20+ "draw" : 10 ,
21+ "recordsTotal" : 10 ,
22+ "recordsFiltered" : 10 ,
23+ "data" : [{
24+ "id" : 476 ,
25+ "name" : " Esmeralda Kulas" ,
26+ "email" : " abbott.cali@heaney.info" ,
27+ "created_at" : " 2016-07-31 23:26:14" ,
28+ "updated_at" : " 2016-07-31 23:26:14" ,
29+ "deleted_at" : null ,
30+ "superior_id" : 0
31+ }, {
32+ "id" : 6 ,
33+ "name" : " Zachery Muller" ,
34+ "email" : " abdullah.koelpin@yahoo.com" ,
35+ "created_at" : " 2016-07-31 23:25:43" ,
36+ "updated_at" : " 2016-07-31 23:25:43" ,
37+ "deleted_at" : null ,
38+ "superior_id" : 1
39+ }, ... ]
40+ }
41+ ```
You can’t perform that action at this time.
0 commit comments