diff --git a/innopacks/panel/routes/web.php b/innopacks/panel/routes/web.php index 489df923..588f7819 100644 --- a/innopacks/panel/routes/web.php +++ b/innopacks/panel/routes/web.php @@ -76,7 +76,7 @@ Route::put('/locales/{country}/active', [Controllers\LocaleController::class, 'active'])->name('locales.active'); Route::get('/themes', [Controllers\ThemeController::class, 'index'])->name('themes.index'); - Route::put('/themes/{country}/active', [Controllers\ThemeController::class, 'enable'])->name('themes.active'); + Route::put('/themes/{code}/active', [Controllers\ThemeController::class, 'enable'])->name('themes.active'); Route::get('/themes/settings', [Controllers\ThemeController::class, 'settings'])->name('themes_settings.index'); Route::put('/themes/settings', [Controllers\ThemeController::class, 'updateSettings'])->name('themes_settings.update'); diff --git a/innopacks/panel/src/Controllers/ThemeController.php b/innopacks/panel/src/Controllers/ThemeController.php index c97e5d75..e607cf90 100644 --- a/innopacks/panel/src/Controllers/ThemeController.php +++ b/innopacks/panel/src/Controllers/ThemeController.php @@ -16,6 +16,7 @@ use InnoShop\Common\Repositories\PageRepo; use InnoShop\Common\Repositories\SettingRepo; use InnoShop\Panel\Repositories\ThemeRepo; +use Throwable; class ThemeController extends BaseController { @@ -49,7 +50,7 @@ public function settings(): mixed /** * @param Request $request * @return mixed - * @throws \Throwable + * @throws Throwable */ public function updateSettings(Request $request): mixed { @@ -68,14 +69,20 @@ public function updateSettings(Request $request): mixed } /** + * @param Request $request * @param string $themeCode * @return JsonResponse - * @throws \Throwable + * @throws Throwable */ - public function enable(string $themeCode): JsonResponse + public function enable(Request $request, string $themeCode): JsonResponse { try { - SettingRepo::getInstance()->updateSystemValue('theme', $themeCode); + $status = $request->get('status'); + if (empty($status)) { + SettingRepo::getInstance()->updateSystemValue('theme', ''); + } else { + SettingRepo::getInstance()->updateSystemValue('theme', $themeCode); + } return json_success(panel_trans('common.updated_success')); } catch (\Exception $e) {