@@ -140,7 +140,7 @@ protected function joinEagerLoadedColumn($relation, $relationColumn)
140
140
$ table = '' ;
141
141
$ deletedAt = false ;
142
142
$ lastQuery = $ this ->query ;
143
- foreach (explode ('. ' , $ relation ) as $ index => $ eachRelation ) {
143
+ foreach (explode ('. ' , $ relation ) as $ eachRelation ) {
144
144
$ model = $ lastQuery ->getRelation ($ eachRelation );
145
145
switch (true ) {
146
146
case $ model instanceof BelongsToMany:
@@ -169,24 +169,19 @@ protected function joinEagerLoadedColumn($relation, $relationColumn)
169
169
170
170
case $ model instanceof BelongsTo:
171
171
$ table = $ model ->getRelated ()->getTable ();
172
- $ alias = "{$ table }_ {$ index }" ;
173
- $ tableAs = "{$ table } AS {$ alias }" ;
174
172
$ foreign = $ model ->getQualifiedForeignKeyName ();
175
- $ other = "{ $ alias } . { $ model ->getOwnerKeyName ()}" ;
173
+ $ other = $ model ->getQualifiedOwnerKeyName () ;
176
174
$ deletedAt = $ this ->checkSoftDeletesOnModel ($ model ->getRelated ());
177
-
178
175
break ;
179
176
180
177
default :
181
178
throw new Exception ('Relation ' . get_class ($ model ) . ' is not yet supported. ' );
182
179
}
183
- $ this ->performJoin ($ tableAs ?? $ table , $ foreign , $ other , $ deletedAt );
180
+ $ this ->performJoin ($ table , $ foreign , $ other , $ deletedAt );
184
181
$ lastQuery = $ model ->getQuery ();
185
182
}
186
183
187
- $ table = $ alias ?? $ table ;
188
-
189
- return "{$ table }. {$ relationColumn }" ;
184
+ return $ table . '. ' . $ relationColumn ;
190
185
}
191
186
192
187
protected function checkSoftDeletesOnModel ($ model )
0 commit comments