original_string: public static function saveOrder($tree = [], $parentId = 0)
      {
          if (empty(static::$branchOrder)) {
              static::setBranchOrder($tree);
          }
  
          foreach ($tree as $branch) {
              $node = static::find($branch['id']);
  
              $node->{$node->getParentColumn()} = $parentId;
              $node->{$node->getOrderColumn()} = static::$branchOrder[$branch['id']];
              $node->save();
  
              if (isset($branch['children'])) {
                  static::saveOrder($branch['children'], $branch['id']);
              }
          }
      }
code: public static function saveOrder($tree = [], $parentId = 0)
      {
          if (empty(static::$branchOrder)) {
              static::setBranchOrder($tree);
          }
  
          foreach ($tree as $branch) {
              $node = static::find($branch['id']);
  
              $node->{$node->getParentColumn()} = $parentId;
              $node->{$node->getOrderColumn()} = static::$branchOrder[$branch['id']];
              $node->save();
  
              if (isset($branch['children'])) {
                  static::saveOrder($branch['children'], $branch['id']);
              }
          }
      }
code_tokens: public static function saveOrder ( $ tree = [ ] , $ parentId = 0 ) { if ( empty ( static :: $ branchOrder ) ) { static :: setBranchOrder ( $ tree ) ; } foreach ( $ tree as $ branch ) { $ node = static :: find ( $ branch [ 'id' ] ) ; $ node -> { $ node -> getParentColumn ( ) } = $ parentId ; $ node -> { $ node -> getOrderColumn ( ) } = static :: $ branchOrder [ $ branch [ 'id' ] ] ; $ node -> save ( ) ; if ( isset ( $ branch [ 'children' ] ) ) { static :: saveOrder ( $ branch [ 'children' ] , $ branch [ 'id' ] ) ; } } }
docstring: Save tree order from a tree like array.
  
  @param array $tree
  @param int   $parentId
docstring_tokens: Save tree order from a tree like array .