Skip to content

Finding menu items

Denis Duliçi edited this page Apr 11, 2019 · 1 revision

To find menu items, you can use findBy method from Akaunting\Menu\MenuBuilder class.

$menu = menu()->instance('sidebar');

$menu->url('profile', 'Profile');

$menu_item = $menu->findBy('title', 'Profile');

// add child menu
$menu_item->url('foo', 'Foo');

You may also use whereTitle helper method to find a specific menu item. Also, you can add other child menu item in the callback that located in the second argument in whereTitle method.

$menu = menu()->instance('sidebar');

$menu->url('profile', 'Profile');

$menu->whereTitle('Profile', function ($sub) {
    // add child menu
    $sub->url('foo', 'Foo');
});
Clone this wiki locally