cms/app/Http/Controllers/Admin/Settings/SettingUpdateController.php
Funky Waddle 37ed997989 feat(cms): initialize Laravel project structure and core CMS files
- Added standard Laravel directory structure and configuration.

- Included Svelte and Tailwind configuration for the admin interface.

- Added core PHPUnit and testing scripts.
2026-04-13 12:48:06 -05:00

58 lines
1.8 KiB
PHP

<?php
namespace App\Http\Controllers\Admin\Settings;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\Settings\UpdateSettingRequest;
use App\Services\SettingService;
/**
* Controller to handle updating site-wide settings.
*/
class SettingUpdateController extends Controller
{
/**
* Update the site settings.
*
* @param UpdateSettingRequest $request
* @param SettingService $settingService
* @return \Illuminate\Http\RedirectResponse
*/
public function __invoke(UpdateSettingRequest $request, SettingService $settingService)
{
$validated = $request->validated();
// Group settings appropriately
$general = [
'site_title' => $validated['site_title'],
];
$seo = [
'seo_description' => $validated['seo_description'] ?? '',
'seo_keywords' => $validated['seo_keywords'] ?? [],
];
$localization = [
'supported_languages' => $validated['supported_languages'],
'default_locale' => $validated['default_locale'],
];
$translation = [
'translation_driver' => $validated['translation_driver'],
'google_translate_key' => $validated['google_translate_key'] ?? '',
];
// Update settings via service
$settingService->updateSettings($general, 'general');
$settingService->updateSettings($seo, 'seo');
$settingService->updateSettings($localization, 'localization');
$settingService->updateSettings($translation, 'translation');
if ($request->wantsJson()) {
return response()->json(['status' => 'Settings updated successfully.']);
}
return redirect()->back()->with('status', 'Settings updated successfully.');
}
}