service = $service; } /** * API 7 - 一覧取得 * GET /api/user-information-history * * @param UserInformationHistoryIndexRequest $request * @return JsonResponse */ public function index(UserInformationHistoryIndexRequest $request): JsonResponse { try { $result = $this->service->getList($request->validated()); return response()->json([ 'result' => 'OK', 'data' => $result['data'], 'pagination' => $result['pagination'], ], 200); } catch (ApiException $e) { return $e->render(); } } /** * API 7 - 単一取得 * GET /api/user-information-history/{id} * * @param int $id * @return JsonResponse */ public function show(int $id): JsonResponse { try { $data = $this->service->getById($id); return response()->json([ 'result' => 'OK', 'data' => $data, ], 200); } catch (ApiException $e) { return $e->render(); } } /** * API 8 - 新規追加 * POST /api/user-information-history * * @param UserInformationHistoryStoreRequest $request * @return JsonResponse */ public function store(UserInformationHistoryStoreRequest $request): JsonResponse { try { $data = $this->service->create($request->validated()); return response()->json(array_merge( ['result' => 'OK'], $data ), 201); } catch (ApiException $e) { return $e->render(); } } /** * API 9 - 更新 * PUT /api/user-information-history/{id} * * @param UserInformationHistoryUpdateRequest $request * @param int $id * @return JsonResponse */ public function update(UserInformationHistoryUpdateRequest $request, int $id): JsonResponse { try { $data = $this->service->update($id, $request->validated()); return response()->json(array_merge( ['result' => 'OK'], $data ), 200); } catch (ApiException $e) { return $e->render(); } } }