worker app age field change

This commit is contained in:
mohanmd 2026-07-07 17:43:44 +05:30
parent 528b13bca1
commit 636d3009a4
3 changed files with 45 additions and 3 deletions

View File

@ -133,7 +133,21 @@ public function updateProfile(Request $request, $id)
'salary' => 'nullable|numeric',
'nationality' => 'nullable|string',
'visa_status' => 'nullable|string',
'age' => 'nullable|integer',
'age' => [
'nullable',
function ($attribute, $value, $fail) {
if (is_numeric($value)) {
$intValue = (int)$value;
if ($intValue < 18 || $intValue > 100) {
$fail('The age must be between 18 and 100.');
}
} else {
if (!in_array($value, ['18-25', '26-35', '36-45', '46-55', '56-60'])) {
$fail('The age must be a valid number or one of the ranges: 18-25, 26-35, 36-45, 46-55, 56-60.');
}
}
}
],
'in_country' => 'nullable',
'preferred_job_type' => 'nullable|string',
'skills' => 'nullable|string',

View File

@ -315,7 +315,21 @@ public function register(Request $request)
'skills' => 'nullable',
'language' => 'nullable|string',
'nationality' => 'nullable|string|max:100',
'age' => 'nullable|string|in:18-25,26-35,36-45,46-55,56-60',
'age' => [
'nullable',
function ($attribute, $value, $fail) {
if (is_numeric($value)) {
$intValue = (int)$value;
if ($intValue < 18 || $intValue > 100) {
$fail('The age must be between 18 and 100.');
}
} else {
if (!in_array($value, ['18-25', '26-35', '36-45', '46-55', '56-60'])) {
$fail('The age must be a valid number or one of the ranges: 18-25, 26-35, 36-45, 46-55, 56-60.');
}
}
}
],
'experience' => 'nullable|string|max:100',
'in_country' => 'nullable',
'visa_status' => 'nullable|string',

View File

@ -70,7 +70,21 @@ public function updateProfile(Request $request)
$validator = Validator::make($request->all(), [
'name' => 'nullable|string|max:255',
'phone' => 'nullable|string|max:50|unique:workers,phone,' . $worker->id,
'age' => 'nullable|string|in:18-25,26-35,36-45,46-55,56-60',
'age' => [
'nullable',
function ($attribute, $value, $fail) {
if (is_numeric($value)) {
$intValue = (int)$value;
if ($intValue < 18 || $intValue > 100) {
$fail('The age must be between 18 and 100.');
}
} else {
if (!in_array($value, ['18-25', '26-35', '36-45', '46-55', '56-60'])) {
$fail('The age must be a valid number or one of the ranges: 18-25, 26-35, 36-45, 46-55, 56-60.');
}
}
}
],
'nationality' => 'nullable|string|max:100',
'language' => 'nullable|string',
'salary' => 'nullable|numeric|min:0',