From 3b6e38da2ed040e24e22e8acb6a3c4d23091f182 Mon Sep 17 00:00:00 2001 From: Paul Dwight Date: Wed, 3 Jan 2024 16:12:44 +0000 Subject: [PATCH 1/2] there is no default sort on the ancestors so we should apply an order to build the ancestor slug properly --- src/Models/Behaviors/HasNesting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/Behaviors/HasNesting.php b/src/Models/Behaviors/HasNesting.php index 7d27a82bd..b6ef0b30a 100644 --- a/src/Models/Behaviors/HasNesting.php +++ b/src/Models/Behaviors/HasNesting.php @@ -35,7 +35,7 @@ public function getNestedSlugAttribute() */ public function getAncestorsSlug(?string $locale = null): string { - return $this->getAncestors()->reverse() + return $this->getAncestors()->sortBy('_lft') ->map(function ($i) use ($locale) { return $i->getSlug($locale); }) From 45a5c4a6724abbdd54d93aef7dbb24e76c96a073 Mon Sep 17 00:00:00 2001 From: Paul Dwight Date: Wed, 10 Jan 2024 10:12:53 +0000 Subject: [PATCH 2/2] updated to use package method to get name of lft node --- src/Models/Behaviors/HasNesting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/Behaviors/HasNesting.php b/src/Models/Behaviors/HasNesting.php index b6ef0b30a..324168232 100644 --- a/src/Models/Behaviors/HasNesting.php +++ b/src/Models/Behaviors/HasNesting.php @@ -35,7 +35,7 @@ public function getNestedSlugAttribute() */ public function getAncestorsSlug(?string $locale = null): string { - return $this->getAncestors()->sortBy('_lft') + return $this->getAncestors()->sortBy($this->getLftName()) ->map(function ($i) use ($locale) { return $i->getSlug($locale); })