feat(scanner): add scanner category validation logic and related tests
This commit is contained in:
@@ -16,6 +16,10 @@ class UpdateStaffRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
$staffId = (int) $this->route('staff');
|
||||
$categoryRules = $this->user()->tenant()->firstOrFail()
|
||||
->requiresScannerCategoryValidation()
|
||||
? ['required', 'array', 'min:1']
|
||||
: ['sometimes', 'array'];
|
||||
|
||||
return [
|
||||
'nombre_apellido' => ['required', 'string', 'max:255'],
|
||||
@@ -26,8 +30,8 @@ class UpdateStaffRequest extends FormRequest
|
||||
'max:255',
|
||||
Rule::unique('users', 'email')->ignore($staffId),
|
||||
],
|
||||
'category_ids' => ['required', 'array', 'min:1'],
|
||||
'category_ids.*' => ['required', 'integer', 'distinct', Rule::exists('categorias', 'id')],
|
||||
'category_ids' => $categoryRules,
|
||||
'category_ids.*' => ['integer', 'distinct', Rule::exists('categorias', 'id')],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user