authenticatedUserIdOrUnauthorized(); if ($guard instanceof JsonResponse) { return $guard; } $prefs = $this->styleService->update($guard, $request->validated()); return $this->success([ 'preferences' => new UiStyleResource($prefs), ], 'Style updated.'); } /** * @return int|JsonResponse */ private function authenticatedUserIdOrUnauthorized(): int|JsonResponse { $userId = (int) (auth()->id() ?? 0); if ($userId <= 0) { return $this->error('Unauthorized.', Response::HTTP_UNAUTHORIZED); } return $userId; } }