Great Package!
Is there some facade method to check if specified module is enabled ? I tried Module::has('name') but it returns true even if module is disabled. Another option I have is to create custom function that would check if given module exists in collection returned by Module::enabled().
So out of curiosity, is there any Module::isEnabled('name') function already there if I am missing it or you plan to add this ?
For example, I want to show menu link only if module is enabled:
@if(Module::has('Court'))
<li><a href="{{route('court_list')}}">Court</a></li>
@endif
Thanks
Currently, there is no such method to straight up check 1 specific module.
You have to write your own using Module::enabled(); or Module::getByStatus(1); or Module::toCollection(); where all of those return all enabled modules.
The ::has() one just checks if it exists in the system.
Also could be a nice candidate for PR.
okay for now, I created this function:
````
/**
foreach ($enabledModules as $module) {
if (strtolower($module->name) === strtolower($moduleName)) {
return true;
}
}
return false;
}
````
Module was made Macroable in #116, you could use that and then should be able to something like this:
Module::macro('isModuleEnabled', function ($moduleName) {
if ($this->has($moduleName)) {
$module = $this->find($moduleName);
return $module->isStatus(1);
}
return false;
});
I would put it in the register() method of a service provider. It could be one you place in the /app/Providers directory (and load through /config/app.php) or one from a core module.
On Jan 18, 2017, 1:36 AM -0700, Sarfraz Ahmed notifications@github.com, wrote:
@mikemand Where exactly do we add this macro, which file ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
I created macros.php file and am loading it via module.json through files section.
\Module::collections() returns a collection of all enabled modules, so you could do
\Module::collections()->has('module name here');
Most helpful comment
\Module::collections()returns a collection of all enabled modules, so you could do\Module::collections()->has('module name here');