Files
InvoiceShelf/app/Platform/Operations/Http/Admin/SettingsController.php
T
Darko Gjorgjijoski 7db2a8d094 feat(operations): fresh platform-operations implementation
Full rewrite of the installer (incl. the finish step), self-update pipeline,
settings store, cron webhook, dashboard/bootstrap surface, environment
manager, wizard login, config endpoint and shared helpers. Byte-compatible
public interfaces and observable behavior, including documented legacy
quirks; verified by the pilot behavioral suite and the full test suite.
2026-08-20 18:30:12 +02:00

47 lines
1.3 KiB
PHP

<?php
namespace App\Platform\Operations\Http\Admin;
use App\Platform\Http\Controller;
use App\Platform\Operations\Http\Requests\GetSettingRequest;
use App\Platform\Operations\Http\Requests\SettingRequest;
use App\Platform\Operations\Models\Setting;
use Illuminate\Http\JsonResponse;
/**
* Read and write access to the instance-wide settings store.
*/
class SettingsController extends Controller
{
/**
* Return a single option, keyed by the option name that was asked for.
* An option that has never been written answers with null, not a 404.
*/
public function show(GetSettingRequest $request): JsonResponse
{
$this->authorize('manage settings');
$key = $request->input('key');
return response()->json([$key => Setting::getSetting($key)]);
}
/**
* Upsert every submitted option.
*
* The echoed payload sits at numeric index 0 rather than under a named
* property, so the body serialises as {"success": true, "0": {...}}.
* Clients only read `success`; the shape is kept as it is.
*/
public function update(SettingRequest $request): JsonResponse
{
$this->authorize('manage settings');
$settings = $request->input('settings');
Setting::setSettings($settings);
return response()->json(['success' => true, $settings]);
}
}