toArray(); return view('admin.settings', compact('settings')); } public function update(Request $request): RedirectResponse { $data = $request->validate([ 'site_name' => ['required', 'string', 'max:80'], 'site_description' => ['nullable', 'string', 'max:255'], 'seo_title_default' => ['nullable', 'string', 'max:160'], 'seo_description_default' => ['nullable', 'string', 'max:255'], 'icp_no' => ['nullable', 'string', 'max:60'], 'security_filing_no' => ['nullable', 'string', 'max:60'], 'logo_url' => ['nullable', 'string', 'max:255'], 'favicon_url' => ['nullable', 'string', 'max:255'], 'contact_email' => ['nullable', 'email', 'max:120'], 'theme' => ['nullable', 'string', 'in:azure,slate,indigo,teal,amber'], 'footer_content' => ['nullable', 'string', 'max:20000'], ]); $seoKeys = ['site_description', 'seo_title_default', 'seo_description_default']; foreach ($data as $key => $value) { $group = in_array($key, $seoKeys, true) ? 'seo' : 'general'; Setting::set($key, $value ?: null, $group); } return redirect()->route('admin.settings')->with('success', '站点设置已保存'); } }