protected function addItem($item, $options = [])
    {
        $nextTo = array_get($options, 'next_to');
        $position = false;
        foreach ($this->items as $index => $m) {
            if ($m['id'] == $nextTo) {
                $position = $index;
            }
        }

        $newMenu = [
            'item'      => $item,
            'before'    => array_get($options, 'before', ''),
            'after'     => array_get($options, 'after', ''),
            'url_def'   => array_get($options, 'url_def'),
            'is_active' => array_get($options, 'is_active'),
            'id'        => array_get($options, 'id'),
        ];

        if ($position !== false) {
            array_splice($this->items, $position + 1, 0, [$newMenu]);
        } else {
            $this->items[] = $newMenu;
        }

        return $this;
    }
protected function addItem($item, $options = [])
    {
        $nextTo = array_get($options, 'next_to');
        $position = false;
        foreach ($this->items as $index => $m) {
            if ($m['id'] == $nextTo) {
                $position = $index;
            }
        }

        $newMenu = [
            'item'      => $item,
            'before'    => array_get($options, 'before', ''),
            'after'     => array_get($options, 'after', ''),
            'url_def'   => array_get($options, 'url_def'),
            'is_active' => array_get($options, 'is_active'),
            'id'        => array_get($options, 'id'),
        ];

        if ($position !== false) {
            array_splice($this->items, $position + 1, 0, [$newMenu]);
        } else {
            $this->items[] = $newMenu;
        }

        return $this;
    }
protected function addItem ( $ item , $ options = [ ] ) { $ nextTo = array_get ( $ options , 'next_to' ) ; $ position = false ; foreach ( $ this -> items as $ index => $ m ) { if ( $ m [ 'id' ] == $ nextTo ) { $ position = $ index ; } } $ newMenu = [ 'item' => $ item , 'before' => array_get ( $ options , 'before' , '' ) , 'after' => array_get ( $ options , 'after' , '' ) , 'url_def' => array_get ( $ options , 'url_def' ) , 'is_active' => array_get ( $ options , 'is_active' ) , 'id' => array_get ( $ options , 'id' ) , ] ; if ( $ position !== false ) { array_splice ( $ this -> items , $ position + 1 , 0 , [ $ newMenu ] ) ; } else { $ this -> items [ ] = $ newMenu ; } return $ this ; }
Add new item to this menu

@param mixed $item
@param array $options

@return Menu
Add new item to this menu