authorize('viewAny', Setting::class); return $this->success([ 'settings' => new SettingsResource($this->settingsService->get()), ]); } public function update(SettingsUpdateRequest $request): JsonResponse { $settings = Setting::singleton(); $this->authorize('update', $settings); $userId = (int) (auth()->id() ?? 0); if ($userId <= 0) { return $this->error('Unauthorized.', Response::HTTP_UNAUTHORIZED); } try { $updated = $this->settingsService->update($request->validated(), $userId); } catch (\Throwable $e) { Log::error('Settings update failed: ' . $e->getMessage()); return $this->error('Unable to update settings.', Response::HTTP_INTERNAL_SERVER_ERROR); } return $this->success([ 'settings' => new SettingsResource($updated), ], 'Settings updated.'); } }