public function run() { \DB::table('fbf_nav_items')->delete(); $types = \Config::get('laravel-navigation::types'); $roots = array_keys($types); foreach ($roots as $root) { NavItem::create(array('title' => $root)); } }
public function generateItem(NavItem $item) { $view = 'item'; $data = ['item' => $item]; $active = $this->collection->active; if ($item->hasChild()) { $data = array_merge($data, ['child' => $item->child]); if ($item->child->isActive($active)) { $view = 'child_active'; } else { $view = 'child'; } } elseif ($item->isActive($active)) { $view = 'item_active'; } else { $view = 'item'; } return view($this->views[$view], $data)->render(); }
protected function getNavigation() { if (!is_null($this->options['from_item_id'])) { $navigationRootNode = NavItem::where('id', '=', $this->options['from_item_id'])->first(); } elseif ($this->options['from_depth'] > 1 && !is_null($this->effectiveRouteNode)) { $navigationRootNode = $this->effectiveRouteNode->ancestorsAndSelf()->where('depth', '=', $this->options['from_depth'] - 1)->first(); } else { $navigationRootNode = NavItem::roots()->where('title', '=', $this->type)->first(); } if (!$navigationRootNode) { return false; } $firstLevelNavItems = $navigationRootNode->getImmediateDescendants(); $navigation = $this->makeNavigation($firstLevelNavItems); return $navigation; }
private function getUniqueUrl(NavItem $item) { $url = $item->getUrl(); $action = $item->getAction(); $params = $item->getParams(); if (isset($action)) { $url = $url . '?' . self::$action . '=' . $action; } if (isset($params)) { $url = $url . '&' . self::$params . '=' . $params; } return $url; }