readStatuses() as $module => $enabled) { if (! is_string($module) || trim($module) === '') { continue; } ModuleStatus::query()->firstOrCreate( ['module' => trim($module)], ['enabled' => (bool) $enabled] ); } } /** * @return array */ private function readStatuses(): array { $path = $this->statusesFilePath(); if ($path === null) { return []; } $statuses = json_decode(File::get($path), true); if (! is_array($statuses)) { return []; } return $statuses; } private function statusesFilePath(): ?string { $configuredPath = config('modules.activators.file.statuses-file'); $paths = array_filter(array_unique([ is_string($configuredPath) ? $configuredPath : null, base_path('modules_statuses.json'), base_path('module_statuses.json'), base_path('module_statues.json'), ])); foreach ($paths as $path) { if (File::exists($path)) { return $path; } } return null; } }