Required star rating (#106)

* Required star rating

* rating validation
This commit is contained in:
Chirag Chhatrala 2023-03-22 20:19:00 +05:30 committed by GitHub
parent d362c3e773
commit db43b2825c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -135,6 +135,9 @@ class AnswerFormRequest extends FormRequest
$messages[$property['id'].'.1.required_with'] = "To date is required";
$messages[$property['id'].'.0.before_or_equal'] = "From date must be before or equal To date";
}
if ($property['type'] == 'number' && isset($property['is_rating']) && $property['is_rating']) {
$messages[$property['id'] . '.min'] = "A rating must be selected";
}
}
return $messages;
}
@ -151,6 +154,9 @@ class AnswerFormRequest extends FormRequest
case 'signature':
return ['string'];
case 'number':
if ($property['is_rating'] ?? false) {
return ['numeric', 'min:1'];
}
return ['numeric'];
case 'select':
case 'multi_select':