pp-planer/app/Http/Controllers/SettingsController.php
Thorsten Bus fefa761748 feat(settings): add macro configuration infrastructure
- Migration: settings table with key (unique), value (text), timestamps
- Model: Setting with static get/set helpers using DB upsert
- Controller: SettingsController with index (Inertia) and update (JSON)
- Vue: Settings page with 4 macro fields, auto-save on blur
- Navigation: Einstellungen link in desktop + mobile nav after API-Log
- Shared props: macroSettings added to HandleInertiaRequests
- Integration: ProExportService injects macro into COPYRIGHT group slides
- Gracefully skips macro injection when settings empty/null
2026-03-02 22:00:19 +01:00

44 lines
1 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Setting;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
class SettingsController extends Controller
{
private const MACRO_KEYS = [
'macro_name',
'macro_uuid',
'macro_collection_name',
'macro_collection_uuid',
];
public function index(): Response
{
$settings = [];
foreach (self::MACRO_KEYS as $key) {
$settings[$key] = Setting::get($key);
}
return Inertia::render('Settings', [
'settings' => $settings,
]);
}
public function update(Request $request): JsonResponse
{
$validated = $request->validate([
'key' => ['required', 'string', 'in:'.implode(',', self::MACRO_KEYS)],
'value' => ['nullable', 'string', 'max:500'],
]);
Setting::set($validated['key'], $validated['value']);
return response()->json(['success' => true]);
}
}