public function destroyDescendants() {
    if ( is_null($this->getRight()) || is_null($this->getLeft()) ) return;

    $self = $this;

    $this->getConnection()->transaction(function() use ($self) {
      $self->reload();

      $lftCol = $self->getLeftColumnName();
      $rgtCol = $self->getRightColumnName();
      $lft    = $self->getLeft();
      $rgt    = $self->getRight();

      // Apply a lock to the rows which fall past the deletion point
      $self->newNestedSetQuery()->where($lftCol, '>=', $lft)->select($self->getKeyName())->lockForUpdate()->get();

      // Prune children
      $self->newNestedSetQuery()->where($lftCol, '>', $lft)->where($rgtCol, '<', $rgt)->delete();

      // Update left and right indexes for the remaining nodes
      $diff = $rgt - $lft + 1;

      $self->newNestedSetQuery()->where($lftCol, '>', $rgt)->decrement($lftCol, $diff);
      $self->newNestedSetQuery()->where($rgtCol, '>', $rgt)->decrement($rgtCol, $diff);
    });
  }
public function destroyDescendants() {
    if ( is_null($this->getRight()) || is_null($this->getLeft()) ) return;

    $self = $this;

    $this->getConnection()->transaction(function() use ($self) {
      $self->reload();

      $lftCol = $self->getLeftColumnName();
      $rgtCol = $self->getRightColumnName();
      $lft    = $self->getLeft();
      $rgt    = $self->getRight();

      // Apply a lock to the rows which fall past the deletion point
      $self->newNestedSetQuery()->where($lftCol, '>=', $lft)->select($self->getKeyName())->lockForUpdate()->get();

      // Prune children
      $self->newNestedSetQuery()->where($lftCol, '>', $lft)->where($rgtCol, '<', $rgt)->delete();

      // Update left and right indexes for the remaining nodes
      $diff = $rgt - $lft + 1;

      $self->newNestedSetQuery()->where($lftCol, '>', $rgt)->decrement($lftCol, $diff);
      $self->newNestedSetQuery()->where($rgtCol, '>', $rgt)->decrement($rgtCol, $diff);
    });
  }
public function destroyDescendants ( ) { if ( is_null ( $ this -> getRight ( ) ) || is_null ( $ this -> getLeft ( ) ) ) return ; $ self = $ this ; $ this -> getConnection ( ) -> transaction ( function ( ) use ( $ self ) { $ self -> reload ( ) ; $ lftCol = $ self -> getLeftColumnName ( ) ; $ rgtCol = $ self -> getRightColumnName ( ) ; $ lft = $ self -> getLeft ( ) ; $ rgt = $ self -> getRight ( ) ; // Apply a lock to the rows which fall past the deletion point $ self -> newNestedSetQuery ( ) -> where ( $ lftCol , '>=' , $ lft ) -> select ( $ self -> getKeyName ( ) ) -> lockForUpdate ( ) -> get ( ) ; // Prune children $ self -> newNestedSetQuery ( ) -> where ( $ lftCol , '>' , $ lft ) -> where ( $ rgtCol , '<' , $ rgt ) -> delete ( ) ; // Update left and right indexes for the remaining nodes $ diff = $ rgt - $ lft + 1 ; $ self -> newNestedSetQuery ( ) -> where ( $ lftCol , '>' , $ rgt ) -> decrement ( $ lftCol , $ diff ) ; $ self -> newNestedSetQuery ( ) -> where ( $ rgtCol , '>' , $ rgt ) -> decrement ( $ rgtCol , $ diff ) ; } ) ; }
Prunes a branch off the tree, shifting all the elements on the right
back to the left so the counts work.

@return void;
Prunes a branch off the tree shifting all the elements on the right back to the left so the counts work .