Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class 'Menu' not found #31

Open
PaditechHoaVQ opened this issue Nov 2, 2018 · 3 comments
Open

Class 'Menu' not found #31

PaditechHoaVQ opened this issue Nov 2, 2018 · 3 comments

Comments

@PaditechHoaVQ
Copy link

PaditechHoaVQ commented Nov 2, 2018

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
Copy link
Author

PaditechHoaVQ commented Nov 2, 2018

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']);

        });

@centralcybersecurity
Copy link

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
Copy link

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!



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants