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

Example

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')
                ->make(true);
});