first(); return view('admin.theme.index', compact('settings','title')); } public function update(Request $request) { $request->validate([ 'primary_color' => 'required|string|max:7', 'primary_hover_color' => 'required|string|max:7', 'secondary_color' => 'required|string|max:7', 'success_color' => 'required|string|max:7', 'info_color' => 'required|string|max:7', 'warning_color' => 'required|string|max:7', 'danger_color' => 'required|string|max:7', ]); DB::table('theme_settings') ->where('id', 1) ->update($request->only([ 'primary_color', 'primary_hover_color', 'secondary_color', 'success_color', 'info_color', 'warning_color', 'danger_color' ])); $this->generateThemeCss(); return redirect()->back()->with('success', 'Theme colors updated successfully!'); } protected function generateThemeCss() { $settings = DB::table('theme_settings')->first(); $css = ":root { --primary-color: {$settings->primary_color}; --primary-hover: {$settings->primary_hover_color}; --secondary-color: {$settings->secondary_color}; --success-color: {$settings->success_color}; --info-color: {$settings->info_color}; --warning-color: {$settings->warning_color}; --danger-color: {$settings->danger_color}; }"; $cssDirectory = dirname(base_path()) . '/assets/front'; $filePath = $cssDirectory . '/theme-colors.css'; File::put($filePath, $css); } }