Skip to content

Commit

Permalink
Use shorter table name alias.
Browse files Browse the repository at this point in the history
  • Loading branch information
yajra committed Apr 24, 2019
1 parent f5e9438 commit 4106405
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/EloquentDataTable.php
Expand Up @@ -169,18 +169,18 @@ protected function joinEagerLoadedColumn($relation, $relationColumn)

case $model instanceof BelongsTo:
$table = $model->getRelated()->getTable();
$alias = "alias_{$index}_{$table}";
$alias = "{$table}_{$index}";
$tableAs = "{$table} AS {$alias}";
$foreign = $model->getQualifiedForeignKeyName();
$owner = "{$alias}.{$model->getOwnerKeyName()}";
$other = "{$alias}.{$model->getOwnerKeyName()}";
$deletedAt = $this->checkSoftDeletesOnModel($model->getRelated());

break;

default:
throw new Exception('Relation ' . get_class($model) . ' is not yet supported.');
}
$this->performJoin($tableAs ?? $table, $foreign, $owner ?? $other, $deletedAt);
$this->performJoin($tableAs ?? $table, $foreign, $other, $deletedAt);
$lastQuery = $model->getQuery();
}

Expand Down

0 comments on commit 4106405

Please sign in to comment.