Alright so I'm building multiple packages in my Laravel project, however each package has some administration side with it for example blogs and forums. Now I got my main project, which doesn't do more than supply a pure foundation for all packages.
I got my admin template with it's own main navigation, now I was wondering if there would be a way to dynamically load in extensions of this menu from the packages? Here's the structure of the whole thing:
Resources
- views
- cp
- homer //Name of the template
- master.blade.php
- components
- nav.blade.php
Now inside my package I would have the following structure
views
- cp
- components
- nav.blade.php
What would be the best step to merge all packages with the same structure to merge all nav.blade.php's together?
As a result I ended up creating my own service as follow:
This will read out the correct folder I create my own packages is
After that I updated the AppServiceProvider
in the boot function I did the following
Now I can access main_nav in my blade and use it like
It now prints out all my nav views that I have for each package.
You can see how Laravel does this with email and other notification views by publishing the vendor files. Here's the relevant documentation: publishing views.