Items belong to a group, or to another item for a nested menu. item($name, $callback) creates the item or returns the existing one with the same name.
$group->item('Users', function (Item $item) {
$item->weight(1);
$item->route('admin.users.index');
$item->icon('fa fa-users');
});
| Method | Description |
|---|---|
name(string $name) |
Text of the item (set by item()). |
weight(int $weight) |
Order inside the group (ascending). Must be an integer. |
url(string $url) |
Link of the item. Default: #. |
route(string $name, array $params = []) |
Link from a named route. The route must exist. |
icon(string $class) |
Icon CSS class, e.g. fa fa-users. |
toggleIcon(string $class) |
Icon shown on items with children. Default: fa fa-angle-left. |
isActiveWhen(string $path) |
Path pattern that marks the item active, e.g. admin/users*. |
isNewTab(bool $newTab = true) |
Open the link in a new tab. |
setItemClass(string $class) |
Extra CSS class for the <li>. |
badge(...) / append(...) |
See Badges and appends. |
authorize(...) / authorizePermission(...) |
See Permissions. |
An item is active when the current request path matches its URL (or any path below it), when it matches the isActiveWhen() pattern, or when one of its children is active:
$item->route('admin.users.index'); // active on /admin/users and /admin/users/*
$item->isActiveWhen('admin/members*'); // or on a custom pattern
$group->item('Settings', function (Item $item) {
$item->icon('fa fa-cogs');
$item->item('General', function (Item $item) {
$item->route('admin.settings.general');
});
$item->item('Mail', function (Item $item) {
$item->route('admin.settings.mail');
});
});