Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Nov 1, 2023
1 parent 24e8fbb commit 48199af
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/Utilities/ModuleActivator.php
Expand Up @@ -36,7 +36,9 @@ public function is(Module $module, bool $active): bool
return true;
}

if (! isset($this->statuses[$module->getAlias()])) {
$alias = $module->getAlias();

if (! isset($this->statuses[$alias])) {
if (empty($this->company_id)) {
$company_id = $this->getCompanyId();

Expand All @@ -47,13 +49,13 @@ public function is(Module $module, bool $active): bool
$this->company_id = $company_id;
}

$model = Model::companyId($this->company_id)->alias($module->getAlias())->get('enabled')->first();
$model = Model::companyId($this->company_id)->alias($alias)->get('enabled')->first();
$status = $model ? $model->enabled : false;

$this->setActive($module, $status);
}

return $this->statuses[$module->getAlias()] === $active;
return $this->statuses[$alias] === $active;
}

public function enable(Module $module): void
Expand All @@ -70,7 +72,7 @@ public function setActive(Module $module, bool $active): void
{
$this->statuses[$module->getAlias()] = $active;

Model::alias($module->getAlias())->updateOrCreate([
Model::companyId($this->company_id)->alias($module->getAlias())->updateOrCreate([
'enabled' => $active,
], [
'company_id' => $this->company_id,
Expand All @@ -89,7 +91,7 @@ public function delete(Module $module): void

unset($this->statuses[$module->getAlias()]);

Model::alias($module->getAlias())->delete();
Model::companyId($this->company_id)->alias($module->getAlias())->delete();

$this->flushCache();
}
Expand Down

0 comments on commit 48199af

Please sign in to comment.