Dynamic Menu Management for Laravel Modules Using NWIDART

285 Views Asked by At

I'm working on a Laravel application where I'm utilizing the NWIDART module to split various functions into modules. Currently, I have a predefined approach in my core code to check if a module exists and is enabled, then display a menu based on the module's name.

However, I'm aiming for a more automated solution where newly installed modules can dynamically add menus without requiring manual edits to my base code..

How can I create a system that handles these requirements? Are there any best practices or existing packages that can assist in implementing this dynamic menu management for Laravel modules?

Thank you for any insights or guidance you can provide!

1

There are 1 best solutions below

0
On

I use the same package for modules and had the same need. I solved by taking a cue from this "Laravel-AdminLTE" package which implements what I think you might need.

In this file you can see how the application triggers an event to build the menu, in the various modules' service providers you can "listen" to the event and add items to the menu, as is done here

To build the menu, I also suggest you look at the various filter and active checker classes used by the package