예제 #1
0
 /**
  * Create navigation children
  *
  * @param  int     $parentId
  * @param  int     $navId
  * @param  mixed   $content
  * @param  int     $depth
  * @param  boolean $cat
  * @return void
  */
 protected function createNavChildren($parentId, $navId, $content, $depth = 0, $cat = false)
 {
     $child = $cat ? \Phire\Categories\Table\Categories::findBy(['parent_id' => $content->id], ['order' => 'order ASC']) : \Phire\Content\Table\Content::findBy(['parent_id' => $content->id], ['order' => 'order ASC']);
     if ($child->hasRows()) {
         foreach ($child->rows() as $c) {
             if (isset($c->status) && $c->status == 1 || !isset($c->status)) {
                 $item = new Table\NavigationItems(['navigation_id' => $navId, 'parent_id' => $parentId, 'item_id' => $c->id, 'type' => $cat ? 'category' : 'content', 'name' => $c->title, 'href' => $cat ? '/category' . $c->uri : $c->uri, 'order' => 0]);
                 $item->save();
                 $this->createNavChildren($item->id, $navId, $c, $depth + 1, $cat);
             }
         }
     }
 }