Skip to content

Hiding menu items

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

To hide menu items, you can use hideWhen method from Akaunting\Menu\MenuItem class.

menu()->create('menu-name', function($menu) {
    $menu->url('login', 'Login')->hideWhen(function () {
        return auth()->check();
    });

    $menu->url('register', 'Register')->hideWhen(function () {
        return auth()->check();
    });

    $menu->dropdown('Account', function ($sub) {
       $sub->url('settings', 'Settings');
       $sub->url('admin', 'Admin Panel')->hideWhen(function () {return !auth()->user()->isAdmin();});
    })->hideWhen(function () {return !auth()->check();});
});
Clone this wiki locally