errorCode = $errorCode; $this->httpStatus = $httpStatus; } /** * エラーコード取得 */ public function getErrorCode(): string { return $this->errorCode; } /** * HTTPステータス取得 */ public function getHttpStatus(): int { return $this->httpStatus; } /** * JSONレスポンスを生成 */ public function render(): JsonResponse { return response()->json([ 'error' => [ 'code' => $this->errorCode, 'message' => $this->getMessage() ] ], $this->httpStatus); } }