04a2034975
- storefront 全站改为极简黑白配色:直角、细线分隔、卡片 hover 浅底、深色模式(跟随系统+手动切换) - 抽出 storefront/partials/card 复用卡片 - 一并提交此前暂存的客户端注册 API、站点设置、后台页面与测试 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
61 lines
2.3 KiB
PHP
61 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\WebAdmin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\StoreSettings;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Throwable;
|
|
use Illuminate\View\View;
|
|
|
|
class SettingsController extends Controller
|
|
{
|
|
public function __construct(private readonly StoreSettings $settings)
|
|
{
|
|
}
|
|
|
|
public function show(): View
|
|
{
|
|
return view('admin.settings', [
|
|
'settings' => $this->settings->all(),
|
|
]);
|
|
}
|
|
|
|
public function update(Request $request): RedirectResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'site_name' => ['required', 'string', 'max:120'],
|
|
'site_tagline' => ['required', 'string', 'max:160'],
|
|
'home_title_suffix' => ['required', 'string', 'max:120'],
|
|
'home_eyebrow' => ['required', 'string', 'max:80'],
|
|
'home_headline' => ['required', 'string', 'max:160'],
|
|
'home_lede' => ['required', 'string', 'max:1000'],
|
|
'home_aside_kicker' => ['required', 'string', 'max:80'],
|
|
'home_aside_title' => ['required', 'string', 'max:160'],
|
|
'home_feature_one_title' => ['required', 'string', 'max:120'],
|
|
'home_feature_one_body' => ['required', 'string', 'max:255'],
|
|
'home_feature_two_title' => ['required', 'string', 'max:120'],
|
|
'home_feature_two_body' => ['required', 'string', 'max:255'],
|
|
'home_feature_three_title' => ['required', 'string', 'max:120'],
|
|
'home_feature_three_body' => ['required', 'string', 'max:255'],
|
|
'home_plugins_title' => ['required', 'string', 'max:120'],
|
|
'home_plugins_subtitle' => ['required', 'string', 'max:255'],
|
|
'home_themes_title' => ['required', 'string', 'max:120'],
|
|
'home_themes_subtitle' => ['required', 'string', 'max:255'],
|
|
]);
|
|
|
|
$payload = collect($validated)
|
|
->map(fn ($value) => trim((string) $value))
|
|
->all();
|
|
|
|
try {
|
|
$this->settings->setMany($payload);
|
|
} catch (Throwable $e) {
|
|
return back()->withInput()->with('error', '站点设置保存失败:' . $e->getMessage());
|
|
}
|
|
|
|
return redirect()->route('webadmin.settings')->with('success', '站点设置已更新');
|
|
}
|
|
}
|