Atualizando arquivos

This commit is contained in:
Kenio 2025-08-03 12:23:18 -03:00
parent a9d934b19e
commit 7130e29d26
2 changed files with 25 additions and 10 deletions

View file

@ -33,9 +33,6 @@ try{
$productsId = isset($_POST['products_id']) ? (string)filter_input(INPUT_POST,'products_id', FILTER_SANITIZE_SPECIAL_CHARS) : 0;
$description = isset($_POST['description']) ? (string)filter_input(INPUT_POST, 'description', FILTER_SANITIZE_SPECIAL_CHARS) : '';
echo $productsId;
exit;
/** Validando os campos de entrada */
$CompaniesBudgetsValidate->setBudget($budget);
$CompaniesBudgetsValidate->setDayDue($dayDue);

View file

@ -46,6 +46,9 @@ class CompaniesBudgetsValidate
private $sanitize = null;
private $type = null;
private $input = [];
private $array_de_strings = null;
private $array_de_numeros = null;
private $json_saida = null;
/** Construtor da classe */
function __construct()
@ -145,19 +148,34 @@ class CompaniesBudgetsValidate
}
/** Método trata campo products_id */
public function setProductsId(int $productsId) : void
public function setProductsId(string $productsId) : void
{
/** Trata a entrada da informação */
$this->productsId = $productsId > 0 ? (int)$this->Main->antiInjection($productsId) : 0;
$this->productsId = isset($productsId) ? (string)$this->Main->antiInjection($productsId) : '';
/** Verifica se a informação foi informada */
if($this->productsId ==0)
{
if(empty($this->productsId))
{
/** Adição de elemento */
array_push($this->errors, 'O produto do orçamento deve ser informada');
}
} else {//converte a entrada parra um json
// Passo 1: Separar a string em um array usando a vírgula como delimitador
$this->array_de_strings = explode(',', $productsId);
// O array resultante será ['6', '7', '4', '5'] (valores como strings)
// Passo 2 (Opcional, mas recomendado): Converter os valores de string para inteiros
$this->array_de_numeros = array_map('intval', $this->array_de_strings);
// O array resultante agora é [6, 7, 4, 5] (valores como números)
// Passo 3: Codificar o array em uma string JSON
$json_saida = json_encode($this->array_de_numeros, JSON_PRETTY_PRINT);
}
}
@ -626,11 +644,11 @@ class CompaniesBudgetsValidate
}
/** Método retorna campo products_id */
public function getProductsId() : ? int
public function getProductsId() : ? string
{
/** Retorno da informação */
return (int)$this->productsId;
return (string)$this->productsId;
}