%s', $title); $id = isset($options['id']) ? $options['id'] : $this->id(); $item = new Item($this, $id, $title, $options); if (isset($options['icon'])) { $item->icon($options['icon']); } if (isset($options['role']) || isset($options['permission'])) { $ability = ['admin']; if (isset($options['role'])) { $ability = $ability + explode(',', $options['role']); } $permission = null; if (isset($options['permission'])) { $permission = explode(',', $options['permission']); } $currentUser = Auth::user(); if ($currentUser && $currentUser->ability($ability, $permission)) { $this->items->push($item); } } else { $this->items->push($item); } return $item; } /** * Add an item to a existing menu item as a submenu item. * * @param $id Id of the menu item to attach to * @param $title Title of the sub item * @param string $options * @return Lavary\Menu\Item */ public function addTo($id, $title, $options = '') { $parent = $this->whereId($id)->first(); if (isset($parent)) { if (! isset($this->root[$parent->id])) { $parent->attr(['url' => '#', 'class' => 'treeview']); // $str = ''; // $parent->append($str); $this->root[$parent->id] = true; } $item = $parent->add($title, $options); } else { $item = $this->add($title, $options); } $item->icon('circle-o'); return $item; } }