Skip to content

Commit 1d15cfd

Browse files
authored
Merge pull request #3015 from Laravel-Backpack/fix-for-left-join-clauses
[4.X] Add table prefix to backpack orderBy clauses.
2 parents 8e30181 + 639d5d5 commit 1d15cfd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/app/Http/Controllers/Operations/ListOperation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function search()
100100
// clear any past orderBy rules
101101
$this->crud->query->getQuery()->orders = null;
102102
// apply the current orderBy rules
103-
$this->crud->query->orderBy($column['name'], $column_direction);
103+
$this->crud->query->orderByRaw($this->crud->model->getTable().'.'.$column['name'].' '.$column_direction);
104104
}
105105

106106
// check for custom order logic in the column definition
@@ -126,7 +126,7 @@ public function search()
126126
}
127127
});
128128
if (! $hasOrderByPrimaryKey) {
129-
$this->crud->query->orderByDesc($this->crud->model->getKeyName());
129+
$this->crud->query->orderByRaw($this->crud->model->getTable().'.'.$this->crud->model->getKeyName().' DESC');
130130
}
131131

132132
$entries = $this->crud->getEntries();

0 commit comments

Comments
 (0)