Add handling for forced prices, arrays, and improved type checks

Introduced support for forced pricing in `addItemToOrder` and added stricter validation for array inputs in SQL queries. Enhanced JSON handling in type validation and improved code reuse with new objects. Added new endpoint `/modules/xlvask/related-orders` to fetch related orders by wash IDs.
This commit is contained in:
Jepp9350
2025-05-22 22:51:05 +02:00
parent b42c864bff
commit b837f572af
6 changed files with 87 additions and 7 deletions
+6 -1
View File
@@ -34,6 +34,11 @@ trait route_t
$value_type = gettype($value);
// If the type is Array, or Object, json_decode the value to check if it is a valid JSON
if ($type === 'array' || $type === 'object') {
if (is_array($value)) {
$value = json_encode($value);
} elseif (is_object($value)) {
$value = json_encode($value);
}
$value = json_decode($value, true);
if (json_last_error() !== JSON_ERROR_NONE) {
global $response;
@@ -44,7 +49,7 @@ trait route_t
// Check if the value is of the required type
if ($value_type !== $type) {
global $response;
$response->error('Invalid type. Expected: ' . $type . ' Got: ' . $value_type . ' Value: ' . $value, 400);
$response->error('Invalid type. Expected: ' . $type . ' Got: ' . $value_type . ' Value: ' . (is_array($value) ? json_encode($value) : $value), 400);
}
return true;
}