class RootMenuItem implements ArrayAccess, Arrayable, Countable, IteratorAggregate, Jsonable, JsonSerializable

A root menu item that contains multiple MenuItem classes. This class can only contain some MenuItem, and never other menu variables.

Traits

Implements an add function that inserts MenuItem references; Used in RootMenuItem and MenuItem (by subclassing)

Properties

protected $_items

Methods

add(string $title, string|array|null $config = null)

Adds a new underlying (submenu) MenuItem;

items()

No description

hasSubItems()

No description

replaceItemName($old, $new)

No description

mixed|null
__get($name)

Gets a submenu item using magic

getIterator()

Retrieve an external iterator

boolean
offsetExists(mixed $offset)

Whether a offset exists

mixed
offsetGet(mixed $offset)

Offset to retrieve

void
offsetSet(mixed $offset, mixed $value)

Offset to set

void
offsetUnset(mixed $offset)

Offset to unset

string
toJson(int $options)

Convert the object to its JSON representation.

int
count()

Count elements of an object

mixed
jsonSerialize()

Specify data which should be serialized to JSON

toArray()

No description

Details

in CreatesMenuItems at line 48
MenuItem add(string $title, string|array|null $config = null)

Adds a new underlying (submenu) MenuItem;

Parameters

string $title The title of your menu item. The slug will be assigned automatically via snake_case if you did not assign one using the next argument's array config or
string|array|null $config $config can either be a string, array or null. Each of those choices will have an impact on the returned data. * String (Always returns $this): 1. Giving "/dashboard" will give it a direct URL (relative or not, depending if you preceed it with a /) 2. Giving it "route:admin.dashboard" will resolve the route and assign it to the menu item's url. To add route parameters, you can do "route:admin.dashboard|url,1|user,2", which will create the route with the "url" param as "1" and "user" as "2" * Array (Always returns $this): 1. By giving it an array, you directly specify the configuration and additional data to be passed to the menu item. This allows for quick configuration, rapidly, and directly onto the add function. 2. To set the route, use the route key, for a url, use the url key. * Null (Always returns a new MenuInstance class): 1. Normally, this is used for sub-menus. You can do something simply, like $menu->add('Dashboard')->route('admin.dashboard')

Return Value

MenuItem

at line 30
items()

at line 43
hasSubItems()

at line 54
replaceItemName($old, $new)

Parameters

$old
$new

at line 76
mixed|null __get($name)

Gets a submenu item using magic

Parameters

$name

Return Value

mixed|null

at line 89
Traversable getIterator()

Retrieve an external iterator

Return Value

Traversable An instance of an object implementing Iterator or Traversable

at line 109
boolean offsetExists(mixed $offset)

Whether a offset exists

Parameters

mixed $offset An offset to check for.

Return Value

boolean true on success or false on failure.

The return value will be casted to boolean if non-boolean was returned.

at line 126
mixed offsetGet(mixed $offset)

Offset to retrieve

Parameters

mixed $offset The offset to retrieve.

Return Value

mixed Can return all value types.

at line 146
void offsetSet(mixed $offset, mixed $value)

Offset to set

Parameters

mixed $offset The offset to assign the value to.
mixed $value The value to set.

Return Value

void

at line 163
void offsetUnset(mixed $offset)

Offset to unset

Parameters

mixed $offset The offset to unset.

Return Value

void

at line 175
string toJson(int $options)

Convert the object to its JSON representation.

Parameters

int $options

Return Value

string

at line 190
int count()

Count elements of an object

Return Value

int The custom count as an integer.

The return value is cast to an integer.

at line 203
mixed jsonSerialize()

Specify data which should be serialized to JSON

Return Value

mixed data which can be serialized by json_encode, which is a value of any type other than a resource.

at line 208
toArray()