File tree 1 file changed +11
-6
lines changed
src/Baum/Extensions/Eloquent
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -7,15 +7,20 @@ class Collection extends BaseCollection {
7
7
8
8
public function toHierarchy () {
9
9
$ dict = $ this ->getDictionary ();
10
-
11
- // Enforce sorting by $orderColumn setting in Baum\Node instance
12
- uasort ($ dict , function ($ a , $ b ){
13
- return ($ a ->getOrder () >= $ b ->getOrder ()) ? 1 : -1 ;
14
- });
15
-
16
10
return new BaseCollection ($ this ->hierarchical ($ dict ));
17
11
}
18
12
13
+ public function toSortedHierarchy () {
14
+ $ dict = $ this ->getDictionary ();
15
+
16
+ // Enforce sorting by $orderColumn setting in Baum\Node instance
17
+ uasort ($ dict , function ($ a , $ b ){
18
+ return ($ a ->getOrder () >= $ b ->getOrder ()) ? 1 : -1 ;
19
+ });
20
+
21
+ return new BaseCollection ($ this ->hierarchical ($ dict ));
22
+ }
23
+
19
24
protected function hierarchical ($ result ) {
20
25
foreach ($ result as $ key => $ node )
21
26
$ node ->setRelation ('children ' , new BaseCollection );
You can’t perform that action at this time.
0 commit comments