/**
  * @param Tree $node
  * @param Tree|null $parent
  * @param integer|null $position
  * @return boolean
  */
 protected function saveNode($node, $parent = null, $position = null)
 {
     if (!empty($parent)) {
         $parent = $this->findModel($parent);
         return $node->appendTo($parent, false);
     } else {
         return $node->makeRoot(false);
     }
 }
Esempio n. 2
0
 /**
  * @param Tree|NestedSetsBehavior $node
  * @param array $items
  * @return TreeRecursiveIterator
  */
 public static function buildNodeTree($node, $items = [])
 {
     $items = $items ?: $node->children()->all();
     $tree = self::buildTree($items, $node->{$node->leftAttribute}, $node->{$node->rightAttribute});
     return $tree;
 }