@@ -165,21 +165,21 @@ protected function buildTree(): Collection
165165        if  ($ this  ->modifyQueryUsing ) {
166166            $ query  = $ this  ->getQuery ()->clone ();
167167            $ query  = $ this  ->evaluate ($ this  ->modifyQueryUsing , ['query '  => $ query ]);
168-              
168+ 
169169            if  ($ this  ->withTrashed ) {
170170                $ query ->withTrashed ($ this  ->withTrashed );
171171            }
172-              
172+ 
173173            $ results  = $ query ->get ();
174-              
174+ 
175175            // Store results for additional functionality 
176176            if  ($ this  ->storeResults ) {
177177                $ this  ->results  = $ results ;
178178            }
179-              
179+ 
180180            return  $ this  ->buildTreeFromResults ($ results );
181181        }
182-          
182+ 
183183        // Original logic for non-filtered queries 
184184        $ nullParentQuery  = $ this  ->getQuery ()->clone ()->where ($ this  ->getParentAttribute (), $ this  ->getParentNullValue ());
185185        $ nonNullParentQuery  = $ this  ->getQuery ()->clone ()->whereNot ($ this  ->getParentAttribute (), $ this  ->getParentNullValue ());
@@ -238,11 +238,11 @@ private function buildTreeFromResults($results, $parent = null): Collection
238238
239239        // Recursively build the tree starting from the root (null parent) 
240240        $ rootResults  = $ resultMap [$ parent ] ?? [];
241-          
241+ 
242242        // If we have no root results but we have results, and we're using modifyQueryUsing, 
243243        // it means the query was filtered and might not have proper root items. 
244244        // In this case, show all results as root items to prevent empty trees. 
245-         if  (empty ($ rootResults ) && !empty ($ results ) && $ this  ->modifyQueryUsing ) {
245+         if  (empty ($ rootResults ) && !  empty ($ results ) && $ this  ->modifyQueryUsing ) {
246246            foreach  ($ results  as  $ result ) {
247247                // Build a node and add it to the tree 
248248                $ node  = $ this  ->buildNode ($ result , $ resultMap , $ disabledOptions , $ hiddenOptions );
0 commit comments