src/Gzero/EloquentTree/Model/Tree.php
protected function renderRecursiveTree($node, $tag, Callable $render)
    {
        $out = '';
        $out .= '<' . $tag . ' class="tree tree-level-' . ($node->{$node->getTreeColumn('level')} + 1) . '">';
        foreach ($node->children as $child) {
            if (!empty($child->children)) {
                $level     = $render($child);
                $nextLevel = $this->renderRecursiveTree($child, $tag, $render);
                $out .= preg_replace('/{sub-tree}/', $nextLevel, $level);
            } else {
                $out .= preg_replace('/{sub-tree}/', '', $render($child));
            }
        }
        return $out . '</' . $tag . '>';
    }
protected function renderRecursiveTree($node, $tag, Callable $render)
    {
        $out = '';
        $out .= '<' . $tag . ' class="tree tree-level-' . ($node->{$node->getTreeColumn('level')} + 1) . '">';
        foreach ($node->children as $child) {
            if (!empty($child->children)) {
                $level     = $render($child);
                $nextLevel = $this->renderRecursiveTree($child, $tag, $render);
                $out .= preg_replace('/{sub-tree}/', $nextLevel, $level);
            } else {
                $out .= preg_replace('/{sub-tree}/', '', $render($child));
            }
        }
        return $out . '</' . $tag . '>';
    }
protected function renderRecursiveTree ( $ node , $ tag , Callable $ render ) { $ out = '' ; $ out .= '<' . $ tag . ' class="tree tree-level-' . ( $ node -> { $ node -> getTreeColumn ( 'level' ) } + 1 ) . '">' ; foreach ( $ node -> children as $ child ) { if ( ! empty ( $ child -> children ) ) { $ level = $ render ( $ child ) ; $ nextLevel = $ this -> renderRecursiveTree ( $ child , $ tag , $ render ) ; $ out .= preg_replace ( '/{sub-tree}/' , $ nextLevel , $ level ) ; } else { $ out .= preg_replace ( '/{sub-tree}/' , '' , $ render ( $ child ) ) ; } } return $ out . '</' . $ tag . '>' ; }
Recursive render descendants

@param          $node
@param          $tag
@param callable $render

@return string
Recursive render descendants