Skip to content

Commit df1fdb4

Browse files
authored
also check for a "from" table name when adding aliases
1 parent 40c400e commit df1fdb4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/EloquentDataTable.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,14 @@ protected function joinEagerLoadedColumn($relation, $relationColumn)
246246
protected function performJoin($table, $foreign, $other, $type = 'left'): string
247247
{
248248
$alias = $table;
249-
$joins = [];
249+
$existingTableNames = [$this->getBaseQueryBuilder()->from];
250250

251251
foreach ((array) $this->getBaseQueryBuilder()->joins as $key => $join) {
252-
$joins[] = Str::before($join->table, ' as ');
252+
$existingTableNames[] = Str::before($join->table, ' as ');
253253
}
254254

255-
if (in_array($table, $joins)) {
256-
$index = count(array_filter($joins, function ($n) use ($table) { return $n === $table; })) + 1;
255+
if (in_array($table, $existingTableNames)) {
256+
$index = count(array_filter($existingTableNames, function ($n) use ($table) { return $n === $table; })) + 1;
257257
$alias = $table . '_' . $index;
258258
$other = str_replace($table, $alias, $other);
259259
$table = $table . ' as ' . $alias;

0 commit comments

Comments
 (0)