Caffeinated\Menus\Builder::add PHP Method

add() public method

Add an item to the defined menu.
public add ( string $title, array | string $options = '' ) : Item
$title string
$options array | string
return Item
    public function add($title, $options = '')
    {
        $item = new Item($this, $this->id(), $title, $options);
        $this->items->push($item);
        $this->lastId = $item->id;
        return $item;
    }

Usage Example

示例#1
0
文件: Item.php 项目: tok3/menus
 /**
  * Adds a sub item to the menu.
  *
  * @param  string        $title
  * @param  array|string  $options
  * @return \Caffeinated\Menus\Item
  */
 public function add($title, $options = '')
 {
     if (!is_array($options)) {
         $url = $options;
         $options = array();
         $options['url'] = $url;
     }
     $options['parent'] = $this->id;
     return $this->builder->add($title, $options);
 }
All Usage Examples Of Caffeinated\Menus\Builder::add