diff --git a/app/Livewire/Planning/QualityAssessment/QuestionRanges.php b/app/Livewire/Planning/QualityAssessment/QuestionRanges.php index 593b3bf6a..fcf85a0ab 100644 --- a/app/Livewire/Planning/QualityAssessment/QuestionRanges.php +++ b/app/Livewire/Planning/QualityAssessment/QuestionRanges.php @@ -80,6 +80,11 @@ public function updateMin($index, $value) public function updateMax($index, $value) { try { + // Validar se o valor é um número válido + if (!is_numeric($value)) { + throw new \Exception(__('project/planning.quality-assessment.ranges.invalid-number')); + } + /** * If the new "end" value is the same as the current "end" value, * do nothing @@ -88,8 +93,8 @@ public function updateMax($index, $value) return; } - $this->items[$index]['end'] = round($value, 2); - $this->items[$index + 1]['start'] = round($value + 0.01, 2); + $this->items[$index]['end'] = round((float)$value, 2); + $this->items[$index + 1]['start'] = round((float)$value + 0.01, 2); /** * Update the current "end" value @@ -110,7 +115,7 @@ public function updateMax($index, $value) GeneralScore::updateOrCreate([ 'id_general_score' => $this->items[$index + 1]['id_general_score'] ], [ - 'start' => round($value + 0.01, 2), + 'start' => round((float)$value + 0.01, 2), ]); $this->dispatch('general-scores-generated'); diff --git a/resources/views/livewire/planning/quality-assessment/question-ranges.blade.php b/resources/views/livewire/planning/quality-assessment/question-ranges.blade.php index fd68d9d1a..bd92a07ad 100644 --- a/resources/views/livewire/planning/quality-assessment/question-ranges.blade.php +++ b/resources/views/livewire/planning/quality-assessment/question-ranges.blade.php @@ -19,6 +19,7 @@ max="{{ $sum }}" disabled="{{ !$loop->first }}" style="min-width: 150px" + x-on:keydown="['e', 'E', '+', '-'].includes($event.key) && $event.preventDefault()" />