Skip to content

Commit dbde111

Browse files
committed
Allow orderColumn using closure.
Fix yajra#2159.
1 parent 42cba7f commit dbde111

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/QueryDataTable.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,14 @@ protected function hasOrderColumn($column)
673673
*/
674674
protected function applyOrderColumn($column, $orderable)
675675
{
676-
$sql = $this->columnDef['order'][$column]['sql'];
677-
$sql = str_replace('$1', $orderable['direction'], $sql);
678-
$bindings = $this->columnDef['order'][$column]['bindings'];
679-
$this->query->orderByRaw($sql, $bindings);
676+
$sql = $this->columnDef['order'][$column]['sql'];
677+
if (is_callable($sql)) {
678+
call_user_func($sql, $this->query, $orderable['direction']);
679+
} else {
680+
$sql = str_replace('$1', $orderable['direction'], $sql);
681+
$bindings = $this->columnDef['order'][$column]['bindings'];
682+
$this->query->orderByRaw($sql, $bindings);
683+
}
680684
}
681685

682686
/**

0 commit comments

Comments
 (0)