public static function treeUpperLeafs($root) { $entries = Category::find(['root = :root: AND parent_id IS NULL', 'order' => 'left_key', 'bind' => ['root' => $root]]); return $entries; }
public function treeUpperLeafs($root) { return Category::treeUpperLeafs($root); }
public function saveTreeAction() { if (!$this->request->getPost() || !$this->request->isAjax()) { return $this->flash->error('post ajax required'); } $data = $this->request->getPost('data'); foreach ($data as $el) { if ($el['item_id']) { $model = Category::findFirst($el['item_id']); if ($model) { if ($el['parent_id']) { $model->setParentId($el['parent_id']); } else { $model->setParentId(null); } $model->setDepth($el['depth']); $model->setLeftKey($el['left']); $model->setRightKey($el['right']); $model->update(); } } } $this->returnJSON(['success' => true]); }