From b24af706a03239473ee8df9452beb9353fd135f7 Mon Sep 17 00:00:00 2001 From: Amirmahdi Nourkazemi Date: Wed, 24 Jun 2026 17:24:31 +0330 Subject: [PATCH] feat: add theme update --- app/Http/Controllers/ThemeController.php | 22 ++++++++++++++++++++++ routes/api.php | 2 ++ 2 files changed, 24 insertions(+) diff --git a/app/Http/Controllers/ThemeController.php b/app/Http/Controllers/ThemeController.php index a6c5b5d..030dbc8 100644 --- a/app/Http/Controllers/ThemeController.php +++ b/app/Http/Controllers/ThemeController.php @@ -23,4 +23,26 @@ public function show($id) { return response()->json(Theme::findOrFail($id)); } + + // Edit an existing theme — typically its color map. The `key` is the stable + // identifier the app maps against, so it is intentionally not editable here. + public function update(Request $request, $id) + { + $theme = Theme::findOrFail($id); + + $data = $request->validate([ + 'name' => 'sometimes|string|max:255', + 'colors' => 'sometimes|array', + 'colors.*' => 'nullable|string|max:32', + 'order' => 'sometimes|integer', + 'is_active' => 'sometimes|boolean', + ]); + + $theme->update($data); + + return response()->json([ + 'message' => 'Theme updated successfully', + 'data' => $theme, + ]); + } } diff --git a/routes/api.php b/routes/api.php index 4fe7e37..a9e3437 100644 --- a/routes/api.php +++ b/routes/api.php @@ -202,6 +202,8 @@ /// themes (color themes a scene can use) Route::get('/themes', [ThemeController::class, 'index']); Route::get('/themes/{id}', [ThemeController::class, 'show']); + Route::put('/themes/{id}', [ThemeController::class, 'update']); // edit name / colors / order / active + Route::post('/themes/{id}', [ThemeController::class, 'update']); // same, for method-spoofed clients /// scenes (تنظیمات صحنه) — each scene has an image, optional video, and sound // Consolidated settings screen (all scenes + current user's preferences) in one call.