Method |
Description |
|
__toString ( ) : string |
|
|
add ( Spatie\Menu\Item $item ) |
Add an item to the menu. This also applies all registered filters to the
item. |
|
addIf ( boolean $condition, Spatie\Menu\Item $item ) |
Add an item to the menu if a (non-strict) condition is met. |
|
addItemClass ( string $class ) |
Add a class to all items in the menu. |
|
addItemParentClass ( string $class ) |
Add a parent class to all items in the menu. |
|
append ( string $append ) |
Append a string of html to the menu on render. |
|
appendIf ( boolean $condition, string $append ) : static |
Append the menu with a string of html on render if a certain condition is
met. |
|
applyToAll ( callable $callable ) |
Apply a callable to all existing items, and register it as a filter so it
will get applied to all new items too. If you typehint the item parameter
in the callable, it wil only be applied to items of that type. |
|
blueprint ( ) : static |
Create a empty blueprint of the menu (copies filters and activeClass). |
|
build ( array | Iterator $items, callable $callback, Menu $initial = null ) : static |
Build a new menu from an array. The callback receives a menu instance as
the accumulator, the array item as the second parameter, and the item's
key as the third. |
|
count ( ) : integer |
The amount of items in the menu. |
|
each ( callable $callable ) |
Iterate over all the items and apply a callback. If you typehint the
item parameter in the callable, it wil only be applied to items of that
type. |
|
fill ( array | Iterator $items, callable $callback ) : static |
Fill a menu from an array. The callback receives a menu instance as
the accumulator, the array item as the second parameter, and the item's
key as the third. |
|
html ( string $html, array $parentAttributes = [] ) |
Shortcut function to add raw html to the menu. |
|
htmlIf ( boolean $condition, string $html, array $parentAttributes = [] ) |
Add a chunk of html if a (non-strict) condition is met. |
|
isActive ( ) : boolean |
Determine whether the menu is active. |
|
link ( string $url, string $text ) |
Shortcut function to add a plain link to the menu. |
|
linkIf ( boolean $condition, string $url, string $text ) |
Add a link to the menu if a (non-strict) condition is met. |
|
new ( array $items = [] ) : static |
Create a new menu, optionally prefilled with items. |
|
prepend ( string $prepend ) |
Prepend the menu with a string of html on render. |
|
prependIf ( boolean $condition, string $prepend ) |
Prepend the menu with a string of html on render if a certain condition is
met. |
|
registerFilter ( callable $callable ) |
Register a filter to the menu. When an item is added, all filters will be
applied to the item. If you typehint the item parameter in the callable, it
will only be applied to items of that type. |
|
render ( ) : string |
Render the menu. |
|
setActive ( callable | string $urlOrCallable, string $root = '/' ) |
Set multiple items in the menu as active based on a callable that filters
through items. If you typehint the item parameter in the callable, it will
only be applied to items of that type. |
|
setActiveClass ( string $class ) |
Set the class name that will be used on active items for this menu. |
|
setActiveFromCallable ( callable $callable ) |
|
|
setActiveFromUrl ( string $url, string $root = '/' ) |
Set all relevant children active based on the current request's URL. |
|
setItemAttribute ( string $attribute, string $value = '' ) |
Set an attribute on all items in the menu. |
|
setItemParentAttribute ( string $attribute, string $value = '' ) |
Add a parent attribute to all items in the menu. |
|
submenu ( callable | Menu | Spatie\Menu\Item $header, callable | Menu | null $menu = null ) |
|
|
submenuIf ( boolean $condition, callable | Menu | Spatie\Menu\Item $header, callable | Menu | null $menu = null ) |
|
|
wrap ( string $element, array $attributes = [] ) |
Wrap the menu in an html element. |
|