Skip to content

Latest commit

 

History

History
33 lines (27 loc) · 454 Bytes

response-only.md

File metadata and controls

33 lines (27 loc) · 454 Bytes

Only Response

Get only selected columns in response.

use DataTables;

Route::get('user-data', function() {
	$model = App\User::query();

	return DataTables::eloquent($model)
				->only(['id','name'])
				->toJson();
});

Example Response

{
	"draw": 2,
	"recordsTotal": 10,
	"recordsFiltered": 2,
	"data": [{
		"id": 476,
		"name": "Esmeralda Kulas"
	}, {
		"id": 6,
		"name": "Zachery Muller"
	}]
}