Skip to content

Commit

Permalink
Revert #2051, fix #2058.
Browse files Browse the repository at this point in the history
  • Loading branch information
yajra committed Apr 26, 2019
1 parent 4114813 commit 9bcb828
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/EloquentDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected function joinEagerLoadedColumn($relation, $relationColumn)
$table = '';
$deletedAt = false;
$lastQuery = $this->query;
foreach (explode('.', $relation) as $index => $eachRelation) {
foreach (explode('.', $relation) as $eachRelation) {
$model = $lastQuery->getRelation($eachRelation);
switch (true) {
case $model instanceof BelongsToMany:
Expand Down Expand Up @@ -169,24 +169,19 @@ protected function joinEagerLoadedColumn($relation, $relationColumn)

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

break;

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

$table = $alias ?? $table;

return "{$table}.{$relationColumn}";
return $table . '.' . $relationColumn;
}

protected function checkSoftDeletesOnModel($model)
Expand Down

0 comments on commit 9bcb828

Please sign in to comment.