Order Columns

In some cases, you may want to use a custom order sql for a set of columns. To achieve this, you can use orderColumns api.

Special Variable & Placeholder


In this example, we will order the column name with nulls as last result.

use DataTables;

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

    return DataTables::eloquent($model)
                ->orderColumns(['name', 'email'], '-:column $1')