laravel-menus icon indicating copy to clipboard operation
laravel-menus copied to clipboard

Class 'Menu' not found

Open PaditechHoaVQ opened this issue 7 years ago • 3 comments

Class 'Menu' not found in {dir}\config\support\menus.php. In the file {dir}\config\support\menus.php, I added the following code:

return \Menu::create('sidebar', function ($menu) {
    $menu->setPresenter(NavbarPresenter::class);

    $menu->header('MAIN NAVIGATION');


    $menu->url('home', 'Home', ['target' => 'blank'], ['icon' => 'fa fa-circle-o']);

    $menu->add([
        'route' => [
            'backend.dashboard',
            ['user' => 'nwidart']
        ],
        'title' => 'Visit My Profile',
        'icon'=>'fa fa-circle-o',
        'attributes' => [
            'target' => '_blank'
        ],
    ]);

    $menu->dropdown('Settings', function ($sub) {
        $sub->url('settings/account', 'Account', ['icon' => 'fa fa-circle-o']);
        $sub->url('settings/password', 'Password', ['icon' => 'fa fa-circle-o']);
        $sub->url('settings/design', 'Design', ['icon' => 'fa fa-circle-o']);
    }, ['icon' => 'fa fa-circle-o']);

});

In the file config.app, i added:

'providers' => [
        Nwidart\Menus\MenusServiceProvider::class,
],

 'aliases' => [
        'Menu' => Nwidart\Menus\Facades\Menu::class,
]

but when i run, i received error: Class 'Menu' not found in {dir}\config\support\menus.php

I tried adding the config\support\menus.php file to the composer.json file: "autoload": { "files": ["config/support/menus.php"] }

I still received error Class 'Menu' not found in {dir}\config\support\menus.php

PaditechHoaVQ avatar Nov 02 '18 09:11 PaditechHoaVQ

Let me know where to put the following code:

        \Menu::create('sidebar', function ($menu) {
            $menu->setPresenter(NavbarPresenter::class);

            $menu->header('MAIN NAVIGATION');


            $menu->url('home', 'Home', ['target' => 'blank'], ['icon' => 'fa fa-circle-o']);

            $menu->add([
                'route' => [
                    'backend.dashboard',
                    ['user' => 'nwidart']
                ],
                'title' => 'Visit My Profile',
                'icon'=>'fa fa-circle-o',
                'attributes' => [
                    'target' => '_blank'
                ],
            ]);

            $menu->dropdown('Settings', function ($sub) {
                $sub->url('settings/account', 'Account', ['icon' => 'fa fa-circle-o']);
                $sub->url('settings/password', 'Password', ['icon' => 'fa fa-circle-o']);
                $sub->url('settings/design', 'Design', ['icon' => 'fa fa-circle-o']);
            }, ['icon' => 'fa fa-circle-o']);

        });

PaditechHoaVQ avatar Nov 02 '18 09:11 PaditechHoaVQ

Let me know where to put the following code:

        \Menu::create('sidebar', function ($menu) {
            $menu->setPresenter(NavbarPresenter::class);

            $menu->header('MAIN NAVIGATION');


            $menu->url('home', 'Home', ['target' => 'blank'], ['icon' => 'fa fa-circle-o']);

            $menu->add([
                'route' => [
                    'backend.dashboard',
                    ['user' => 'nwidart']
                ],
                'title' => 'Visit My Profile',
                'icon'=>'fa fa-circle-o',
                'attributes' => [
                    'target' => '_blank'
                ],
            ]);

            $menu->dropdown('Settings', function ($sub) {
                $sub->url('settings/account', 'Account', ['icon' => 'fa fa-circle-o']);
                $sub->url('settings/password', 'Password', ['icon' => 'fa fa-circle-o']);
                $sub->url('settings/design', 'Design', ['icon' => 'fa fa-circle-o']);
            }, ['icon' => 'fa fa-circle-o']);

        });

Hi, I just installed the package, and I am clueless as to which file the --- Menu:create function ---- to be added so that the Menu is available across the website.

did you manage to find it?

Thank you for your help.

centralcybersecurity avatar Jul 23 '21 03:07 centralcybersecurity

If anyone else is looking for the same answer, here's how to call the Menu.

1. Create in app/Support/menus.php

    $menu->url('/', 'Home', ['icon' => 'fa fa-dashboard'])->order(1);
    // $menu->route('/', 'About', ['user' => '1'], ['icon' => 'fa fa-user'])->order(2);
    $menu->dropdown('Settings', function ($sub) {
        $sub->header('ACCOUNT');
        $sub->url('/settings/design', 'Design');
        $sub->divider();
        $sub->url('logout', 'Logout');
    })->order(3);
});```

**2. Render**

{!! Menu::render('navbar', 'nav-tab') !!}

It works!



centralcybersecurity avatar Jul 23 '21 03:07 centralcybersecurity