Example #1
0
 /**
  * Set hierarchy information for new item
  *
  * @param MenuItem $item item object
  * @return void
  */
 protected function setHierarchy(MenuItem $item)
 {
     // 이미 존재하는 경우 hierarchy 정보를 새로 등록하지 않음
     try {
         $item->ancestors()->attach($item->getKey(), [$item->getDepthName() => 0]);
     } catch (\Exception $e) {
         return;
     }
     if ($item->{$item->getParentIdName()}) {
         $parent = $this->repo->findItem($item->{$item->getParentIdName()});
         $this->linkHierarchy($item, $parent);
     }
 }