예제 #1
0
 /**
  * Fixes the tree based on parentage info.
  *
  * Nodes with invalid parent are saved as roots.
  *
  * @return int The number of fixed nodes
  */
 public function fixTree()
 {
     $columns = [$this->model->getKeyName(), $this->model->getParentIdName(), $this->model->getLftName(), $this->model->getRgtName()];
     $dictionary = $this->model->newNestedSetQuery()->defaultOrder()->get($columns)->groupBy($this->model->getParentIdName())->all();
     return self::fixNodes($dictionary);
 }