File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -401,6 +401,27 @@ protected function processForContent()
401401
402402 $ this ->guardAgaintsTableExist ($ model );
403403
404+ $ reorderContent = function ($ collection ) {
405+ return collect ($ collection )
406+ ->sortBy (function ($ item , $ contentKey ) {
407+
408+ $ slugSegments = explode ('/ ' , $ contentKey );
409+
410+ $ haveRootParent = collect ($ slugSegments )->contains ('__root__ ' );
411+
412+ $ segmentCount = count ($ slugSegments );
413+
414+ //Higher Order if have root parent
415+ if ($ haveRootParent ) {
416+ return $ segmentCount ;
417+ }
418+
419+ return 999 ;
420+ });
421+ };
422+
423+ $ this ->pendingData ['content ' ] = $ reorderContent (collect ($ this ->pendingData ['content ' ] ?? []))->toArray ();
424+
404425 foreach ($ this ->pendingData ['content ' ] ?? [] as $ contentKey => $ item ) {
405426
406427 try {
You can’t perform that action at this time.
0 commit comments