authenticatedUserIdOrUnauthorized(); if ($guard instanceof JsonResponse) { return $guard; } $payload = $this->service->buildForUser($guard); return $this->success([ 'profile' => new ProfileIconResource($payload), ]); } private function authenticatedUserIdOrUnauthorized(): int|JsonResponse { $userId = (int) (auth()->id() ?? 0); if ($userId <= 0) { return $this->error('Unauthorized.', Response::HTTP_UNAUTHORIZED); } return $userId; } }