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']);
            }
        }
    }
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']);
            }
        }
    }
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' ] ) ; } } }
Save tree order from a tree like array.

@param array $tree
@param int   $parentId
Save tree order from a tree like array .