Skip to content

WARNING You're browsing the documentation for an old version of LARAVEL-DATATABLES. Consider upgrading your project to laravel-datatables 11.0.

Order Column

In some cases, you may want to use a custom order sql for a specific column. To achieve this, you can use orderColumn api.

{tip} Order column has a special variable $1 which is being replace as the order direction value of the request.

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)
->orderColumn('name', '-name $1')