@@ -34,7 +34,7 @@ public function it_can_perform_global_search()
34
34
['data ' => 'name ' , 'name ' => 'name ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
35
35
['data ' => 'email ' , 'name ' => 'email ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
36
36
],
37
- 'search ' => ['value ' => 'Record-19 ' ],
37
+ 'search ' => ['value ' => 'Record-19 ' ],
38
38
]);
39
39
40
40
$ crawler ->assertJson ([
@@ -52,7 +52,7 @@ public function it_can_skip_total_records_count_query()
52
52
['data ' => 'name ' , 'name ' => 'name ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
53
53
['data ' => 'email ' , 'name ' => 'email ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
54
54
],
55
- 'search ' => ['value ' => 'Record-19 ' ],
55
+ 'search ' => ['value ' => 'Record-19 ' ],
56
56
]);
57
57
58
58
$ crawler ->assertJson ([
@@ -70,7 +70,7 @@ public function it_can_perform_multiple_term_global_search()
70
70
['data ' => 'name ' , 'name ' => 'name ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
71
71
['data ' => 'email ' , 'name ' => 'email ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
72
72
],
73
- 'search ' => ['value ' => 'Record-19 Email-19 ' ],
73
+ 'search ' => ['value ' => 'Record-19 Email-19 ' ],
74
74
]);
75
75
76
76
$ crawler ->assertJson ([
@@ -143,7 +143,7 @@ public function it_does_not_allow_search_on_added_columns()
143
143
['data ' => 'name ' , 'name ' => 'name ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
144
144
['data ' => 'email ' , 'name ' => 'email ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
145
145
],
146
- 'search ' => ['value ' => 'Record-19 ' ],
146
+ 'search ' => ['value ' => 'Record-19 ' ],
147
147
]);
148
148
149
149
$ crawler ->assertJson ([
@@ -153,6 +153,14 @@ public function it_does_not_allow_search_on_added_columns()
153
153
]);
154
154
}
155
155
156
+ /** @test */
157
+ public function it_returns_only_the_selected_columns ()
158
+ {
159
+ $ json = $ this ->call ('GET ' , '/query/only ' )->json ();
160
+ $ this ->assertArrayNotHasKey ('id ' , $ json ['data ' ][0 ]);
161
+ $ this ->assertArrayHasKey ('name ' , $ json ['data ' ][0 ]);
162
+ }
163
+
156
164
/** @test */
157
165
public function it_does_not_allow_raw_html_on_added_columns ()
158
166
{
@@ -187,7 +195,7 @@ public function it_can_return_auto_index_column()
187
195
['data ' => 'name ' , 'name ' => 'name ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
188
196
['data ' => 'email ' , 'name ' => 'email ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
189
197
],
190
- 'search ' => ['value ' => 'Record-19 ' ],
198
+ 'search ' => ['value ' => 'Record-19 ' ],
191
199
]);
192
200
193
201
$ crawler ->assertJson ([
@@ -208,7 +216,7 @@ public function it_allows_search_on_added_column_with_custom_filter_handler()
208
216
['data ' => 'name ' , 'name ' => 'name ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
209
217
['data ' => 'email ' , 'name ' => 'email ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
210
218
],
211
- 'search ' => ['value ' => 'Record-19 ' ],
219
+ 'search ' => ['value ' => 'Record-19 ' ],
212
220
]);
213
221
214
222
$ crawler ->assertJson ([
@@ -256,6 +264,13 @@ protected function setUp(): void
256
264
->toJson ();
257
265
});
258
266
267
+ $ route ->get ('/query/only ' , function (DataTables $ dataTable ) {
268
+ return $ dataTable ->query (DB ::table ('users ' ))
269
+ ->addColumn ('foo ' , 'bar ' )
270
+ ->only (['name ' ])
271
+ ->toJson ();
272
+ });
273
+
259
274
$ route ->get ('/query/xss-add ' , function (DataTables $ dataTable ) {
260
275
return $ dataTable ->query (DB ::table ('users ' ))
261
276
->addColumn ('foo ' , '<a href="#">Allowed</a> ' )
0 commit comments