Skip to content

Commit 92f10d5

Browse files
authored
Merge pull request #2856 from OzanKurt/patch-2
Fixed the search column for same table relations
2 parents f33ef21 + fc523fe commit 92f10d5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/QueryDataTable.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,15 @@ protected function addTablePrefix($query, string $column): string
422422
{
423423
if (! str_contains($column, '.')) {
424424
$q = $this->getBaseQueryBuilder($query);
425+
$from = $q->from;
426+
425427
/** @phpstan-ignore-next-line */
426-
if (! $q->from instanceof Expression) {
427-
$column = $q->from.'.'.$column;
428+
if (! $from instanceof Expression) {
429+
if (str_contains($from, ' as ')) {
430+
$from = explode(' as ', $from)[1];
431+
}
432+
433+
$column = $from . '.' . $column;
428434
}
429435
}
430436

0 commit comments

Comments
 (0)