module activate
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
namespace kernel\services;
|
||||
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\helpers\Manifest;
|
||||
use kernel\models\Option;
|
||||
|
||||
@ -23,7 +24,7 @@ class ModuleService
|
||||
|
||||
public function isActive(string $slug): bool
|
||||
{
|
||||
$active_modules= Option::where("key", "active_modules")->first();
|
||||
$active_modules = Option::where("key", "active_modules")->first();
|
||||
if ($active_modules){
|
||||
$path = json_decode($active_modules->value);
|
||||
foreach ($path->modules as $p){
|
||||
@ -36,4 +37,18 @@ class ModuleService
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setActiveModule(string $module): void
|
||||
{
|
||||
$active_modules = Option::where("key", "active_modules")->first();
|
||||
$path = json_decode($active_modules->value);
|
||||
if (in_array($module, $path->modules)) {
|
||||
unset($path->modules[array_search($module, $path->modules)]);
|
||||
$path->modules = array_values($path->modules);
|
||||
} else {
|
||||
$path->modules[] = $module;
|
||||
}
|
||||
$active_modules->value = json_encode($path, JSON_UNESCAPED_UNICODE);
|
||||
$active_modules->save();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user