@@ -606,8 +606,12 @@ public function resolveRelations(string $relationString, string $parent = '', ar
606606 $ relationModel = inspect ($ currentRelation );
607607 $ modelType = $ relationModel ->getName ();
608608
609+ $ fullPath = $ parent !== ''
610+ ? "{$ parent }. {$ currentRelationName }"
611+ : $ currentRelationName ;
612+
609613 if (in_array ($ modelType , $ visitedPaths , true )) {
610- return [$ currentRelationName => $ currentRelation ->setParent ($ parent )];
614+ return [$ fullPath => $ currentRelation ->setParent ($ parent )];
611615 }
612616
613617 $ newRelationString = implode ('. ' , $ relationNames );
@@ -618,7 +622,7 @@ public function resolveRelations(string $relationString, string $parent = '', ar
618622 $ currentRelationName ,
619623 ), '. ' );
620624
621- $ relations = [$ currentRelationName => $ currentRelation ];
625+ $ relations = [$ fullPath => $ currentRelation ];
622626
623627 return [
624628 ...$ relations ,
@@ -659,7 +663,10 @@ public function resolveEagerRelations(string $parent = '', array $visitedPaths =
659663 continue ;
660664 }
661665
662- $ relations [$ property ->getName ()] = $ currentRelation ->setParent ($ parent );
666+ $ fullPath = $ parent !== ''
667+ ? "{$ parent }. {$ currentRelationName }"
668+ : $ currentRelationName ;
669+ $ relations [$ fullPath ] = $ currentRelation ->setParent ($ parent );
663670 $ newVisitedPaths = [...$ visitedPaths , $ this ->getName ()];
664671
665672 foreach ($ relationModel ->resolveEagerRelations ($ newParent , $ newVisitedPaths ) as $ name => $ nestedEagerRelation ) {
0 commit comments