src/Gzero/EloquentTree/Model/Tree.php
public function setAsRoot()
    {
        $this->handleNewNodes();
        if (!$this->isRoot()) { // Only if it is not already root
            if ($this->fireModelEvent('updatingParent') === false) {
                return $this;
            }
            $oldDescendants                         = $this->getOldDescendants();
            $this->{$this->getTreeColumn('path')}   = $this->getKey() . '/';
            $this->{$this->getTreeColumn('parent')} = null;
            $this->setRelation('parent', null);
            $this->{$this->getTreeColumn('level')} = 0;
            $this->save();
            $this->fireModelEvent('updatedParent', false);
            $this->updateDescendants($this, $oldDescendants);
        }
        return $this;
    }
public function setAsRoot()
    {
        $this->handleNewNodes();
        if (!$this->isRoot()) { // Only if it is not already root
            if ($this->fireModelEvent('updatingParent') === false) {
                return $this;
            }
            $oldDescendants                         = $this->getOldDescendants();
            $this->{$this->getTreeColumn('path')}   = $this->getKey() . '/';
            $this->{$this->getTreeColumn('parent')} = null;
            $this->setRelation('parent', null);
            $this->{$this->getTreeColumn('level')} = 0;
            $this->save();
            $this->fireModelEvent('updatedParent', false);
            $this->updateDescendants($this, $oldDescendants);
        }
        return $this;
    }
public function setAsRoot ( ) { $ this -> handleNewNodes ( ) ; if ( ! $ this -> isRoot ( ) ) { // Only if it is not already root if ( $ this -> fireModelEvent ( 'updatingParent' ) === false ) { return $ this ; } $ oldDescendants = $ this -> getOldDescendants ( ) ; $ this -> { $ this -> getTreeColumn ( 'path' ) } = $ this -> getKey ( ) . '/' ; $ this -> { $ this -> getTreeColumn ( 'parent' ) } = null ; $ this -> setRelation ( 'parent' , null ) ; $ this -> { $ this -> getTreeColumn ( 'level' ) } = 0 ; $ this -> save ( ) ; $ this -> fireModelEvent ( 'updatedParent' , false ) ; $ this -> updateDescendants ( $ this , $ oldDescendants ) ; } return $ this ; }
Set node as root node

@return $this
Set node as root node