Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 547 Bytes

manual-order.md

File metadata and controls

24 lines (18 loc) · 547 Bytes

Manual Order

You may optionally disable the default ordering function of DataTables and write you own using order api.

use DataTables;

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

	return DataTables::eloquent($model)
				->order(function ($query) {
		            if (request()->has('name')) {
		                $query->orderBy('name', 'asc');
		            }

		            if (request()->has('email')) {
		                $query->orderBy('email', 'desc');
		            }
		        })
				->toJson();
});