code = $code; $this->status = $status; return $this; } public function toResponse($request) { return response()->json([ 'data' => [ 'code' => $code = $this->code ?? Response::HTTP_INTERNAL_SERVER_ERROR, 'message' => $this->status ?? Response::$statusTexts[$code], ] ]); } }