Example #1
0
 /**
  * Deletes node and it's descendants.
  * @throws \Exception.
  * @return boolean whether the deletion is successful.
  */
 public function delete()
 {
     if ($this->isLeaf()) {
         $result = parent::delete();
     } else {
         $result = $this->objects()->filter(['lft__gte' => $this->lft, 'rgt__lte' => $this->rgt, 'root' => $this->root])->delete();
     }
     $this->shiftLeftRight($this->rgt + 1, $this->lft - $this->rgt - 1);
     return (bool) $result;
 }