|
@@ -7,26 +7,37 @@
|
|
|
|
|
|
|
|
class StudentRegistrationDraftRequest extends FormRequest
|
|
class StudentRegistrationDraftRequest extends FormRequest
|
|
|
{
|
|
{
|
|
|
|
|
+ protected function prepareForValidation(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ $documentNumber = $this->input('document_number');
|
|
|
|
|
+
|
|
|
|
|
+ if (is_string($documentNumber)) {
|
|
|
|
|
+ $this->merge([
|
|
|
|
|
+ 'document_number' => preg_replace('/\D/', '', $documentNumber),
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function rules(): array
|
|
public function rules(): array
|
|
|
{
|
|
{
|
|
|
return [
|
|
return [
|
|
|
'registration_draft_token' => 'sometimes|nullable|uuid',
|
|
'registration_draft_token' => 'sometimes|nullable|uuid',
|
|
|
- 'name' => 'required|string|max:255',
|
|
|
|
|
- 'birth_date' => 'required|date',
|
|
|
|
|
- 'document_number' => ['sometimes', 'nullable', 'string', 'max:20', Cpf::rule()],
|
|
|
|
|
- 'gender' => 'sometimes|nullable|string|in:no_preference,male,female,other',
|
|
|
|
|
- 'email' => 'sometimes|nullable|email|unique:students,email',
|
|
|
|
|
- 'phone' => 'sometimes|nullable|string|max:20',
|
|
|
|
|
- 'postal_code' => 'sometimes|nullable|string|max:10',
|
|
|
|
|
- 'street' => 'sometimes|nullable|string|max:255',
|
|
|
|
|
- 'address_number' => 'sometimes|nullable|string|max:20',
|
|
|
|
|
- 'neighborhood' => 'sometimes|nullable|string|max:255',
|
|
|
|
|
- 'city_id' => 'sometimes|nullable|integer|exists:cities,id',
|
|
|
|
|
- 'state_id' => 'sometimes|nullable|integer|exists:states,id',
|
|
|
|
|
- 'complement' => 'sometimes|nullable|string|max:255',
|
|
|
|
|
- 'payer_name' => 'sometimes|nullable|string|max:255',
|
|
|
|
|
- 'how_did_you_know_us' => 'sometimes|nullable|string|in:referral,social_media,google,other',
|
|
|
|
|
- 'notes' => 'sometimes|nullable|string',
|
|
|
|
|
|
|
+ 'name' => 'required|string|max:255',
|
|
|
|
|
+ 'birth_date' => 'required|date',
|
|
|
|
|
+ 'document_number' => ['sometimes', 'nullable', 'string', 'max:20', Cpf::rule(), 'unique:students,document_number'],
|
|
|
|
|
+ 'gender' => 'sometimes|nullable|string|in:no_preference,male,female,other',
|
|
|
|
|
+ 'email' => 'sometimes|nullable|email|unique:students,email',
|
|
|
|
|
+ 'phone' => 'sometimes|nullable|string|max:20',
|
|
|
|
|
+ 'postal_code' => 'sometimes|nullable|string|max:10',
|
|
|
|
|
+ 'street' => 'sometimes|nullable|string|max:255',
|
|
|
|
|
+ 'address_number' => 'sometimes|nullable|string|max:20',
|
|
|
|
|
+ 'neighborhood' => 'sometimes|nullable|string|max:255',
|
|
|
|
|
+ 'city_id' => 'sometimes|nullable|integer|exists:cities,id',
|
|
|
|
|
+ 'state_id' => 'sometimes|nullable|integer|exists:states,id',
|
|
|
|
|
+ 'complement' => 'sometimes|nullable|string|max:255',
|
|
|
|
|
+ 'payer_name' => 'sometimes|nullable|string|max:255',
|
|
|
|
|
+ 'how_did_you_know_us' => 'sometimes|nullable|string|in:referral,social_media,google,other',
|
|
|
|
|
+ 'notes' => 'sometimes|nullable|string',
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|