addRoute('GET', '/', [\Modules\Index\Controllers\IndexController::class, 'index']); // Static pages $app->addRoute('GET', '/about', [\Modules\Index\Controllers\IndexController::class, 'about']); $app->addRoute('GET', '/services', [\Modules\Index\Controllers\IndexController::class, 'services']); // Language switcher route $app->addRoute('GET', '/language/{lang}', [\Modules\Index\Controllers\IndexController::class, 'changeLanguage']); // Dynamic pages from ConfigPage if (class_exists('Modules\Configindex\Models\ConfigPage')) { try { $busId = $_SESSION['current_company_id'] ?? 1; $pages = \Modules\Configindex\Models\ConfigPage::where('config_index_bus_id', $busId)->get(); foreach ($pages as $page) { $key = $page->config_index_key; if (!in_array($key, ['index', 'about', 'services', 'contact'])) { $app->addRoute('GET', '/' . $key, function ($request) use ($key) { $controller = \Kernel\Application::getInstance()->getContainer()->get(\Modules\Index\Controllers\IndexController::class); return $controller->page($request, $key); }); } } } catch (\Throwable $e) { // Table might not exist yet } } // Category route $app->addRoute('GET', '/category/{category}', [\Modules\Index\Controllers\IndexController::class, 'category']); };