resultType = 'FAIL'; $this->error = [ 'errorCode' => $errorCode, 'reason' => $reason ]; $this->success = null; } public function __set($name, $value) { $this->{$name} = $value; } public function __get($name): mixed { return ($this->{$name} ?? null); } public function toResponse($request): JsonResponse { return response()->json($this); } }