瀏覽代碼

last fix for event

ljoaquim 3 月之前
父節點
當前提交
75849381d9
共有 2 個文件被更改,包括 5 次插入5 次删除
  1. 4 4
      controllers/CprPreregistrationController.php
  2. 1 1
      models/CprPreregistrationModel.php

+ 4 - 4
controllers/CprPreregistrationController.php

@@ -19,7 +19,7 @@ class CprPreregistrationController
         $email = isset($body['email']) ? trim((string)$body['email']) : '';
         $productType = isset($body['product_type']) ? trim((string)$body['product_type']) : '';
         $internalControlNumber = isset($body['internal_control_number']) ? trim((string)$body['internal_control_number']) : '';
-        $productQuantityRaw = $body['product_quantity'] ?? null;
+        $productQuantityRaw = isset($body['product_quantity']) ? trim((string)$body['product_quantity']) : '';
         $propertyName = isset($body['property_name']) ? trim((string)$body['property_name']) : '';
         $propertyLocation = isset($body['property_location']) ? trim((string)$body['property_location']) : '';
 
@@ -32,7 +32,7 @@ class CprPreregistrationController
             'product_type' => v::stringType()->notEmpty()->alnum(" -_/.,")->length(1, 100),
             'internal_control_number' => v::stringType()->notEmpty()->alnum("-_/.")->length(1, 100),
             // Accept numeric strings convertible to int
-            'product_quantity' => v::stringType()->notEmpty()->alnum("-_/.")->length(1, 100),
+            'product_quantity' => v::stringType()->notEmpty()->alnum(" -_/.,")->length(1, 200),
             'property_name' => v::stringType()->notEmpty()->alnum(" -_/.,")->length(1, 150),
             'property_location' => v::stringType()->notEmpty()->alnum(" -_/.,")->length(1, 200),
         ];
@@ -61,8 +61,8 @@ class CprPreregistrationController
             return ResponseLib::sendFail("Validation failed", ['errors' => $errors], "E_VALIDATE")->withStatus(400);
         }
 
-        // Safe casting after validation
-        $productQuantity = (int)$productQuantityRaw;
+        // Keep as free text after validation
+        $productQuantity = $productQuantityRaw;
 
         try {
             $model = new CprPreregistrationModel();

+ 1 - 1
models/CprPreregistrationModel.php

@@ -20,7 +20,7 @@ class CprPreregistrationModel
         string $email,
         string $productType,
         string $internalControlNumber,
-        int $productQuantity,
+        string $productQuantity,
         string $propertyName,
         string $propertyLocation
     ): array {