Admin Menu Adding Problem

Hi, i have created a new menu in admin with below code in my module.

 AdminMenuFacade::add('storeinfo', function (AdminMenu $storeinfoMenu) {

            $storeinfoMenu->label('Store Info')

                    ->route('#')

                    ->icon('fas fa-building');

        });


        $storeinfoMenu = AdminMenuFacade::get('storeinfo');


        $logoMenu = new AdminMenu();


        $logoMenu->key('log_mgt')

                ->label('Logo Mgt')

                ->icon('fas fa-newspaper')

                ->route('admin.logo.index');

        $storeinfoMenu->subMenu('log_mgt', $logoMenu); 


Now, i am creating another module and adding the route as submenu for the above listed menu, with below code.

 $storeinfoMenu = AdminMenuFacade::get('storeinfo');


        $feviconMenu = new AdminMenu();


        $feviconMenu->key('fevicon_mgt')

                ->label('Fevicon Mgt')

                ->icon('fas fa-newspaper')

                ->route('admin.logo.index');

        $storeinfoMenu->subMenu('fevicon_mgt', $feviconMenu);


but i am getting the error below error.


D:\Projects\avored1\modules\avored\fevicon\src\Module.php
  1. * e.g. Route, View, Database & Translation Path
  2. *
  3. * @return void
  4. */
  5. protected function registerResources() {
  6. //$this->loadRoutesFrom(__DIR__ . '/../routes/web.php');
  7. //$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'avored-fevicon');
  8. //$this->loadViewsFrom(__DIR__ . '/../resources/views', 'avored-fevicon');
  9. }
  10. protected function registerAdminMenu() {
  11. $storeinfoMenu = AdminMenuFacade::get('storeinfo');
  12. $feviconMenu = new AdminMenu();
  13. $feviconMenu->key('fevicon_mgt')
  14. ->label('Fevicon Mgt')
  15. ->icon('fas fa-newspaper')
  16. ->route('admin.logo.index');
  17. $storeinfoMenu->subMenu('fevicon_mgt', $feviconMenu);
  18. }
  19. }
Arguments
  1. "Call to a member function subMenu() on null"


Please check and let me know, if missed anything.

Thank you

Purvesh had replied 9 months ago

To me, it seems like the order in which Module is getting loaded that order is wrong.

Module 2 => AdminMenu => ADD => storeinfo 

Module 1 => AdminMenu => GET => storeinfo 

I hope you get my point. So if you move this code in modules then it should work. Actually i don't have depends module feature now. Move the below code into Module1

 AdminMenuFacade::add('storeinfo', function (AdminMenu $storeinfoMenu) {

            $storeinfoMenu->label('Store Info')

                    ->route('#')

                   ->icon('fas fa-building');

        });

        $storeinfoMenu = AdminMenuFacade::get('storeinfo');