| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace App\Http\Requests;
- use Illuminate\Foundation\Http\FormRequest;
- class StudentRequest extends FormRequest
- {
- public function rules(): array
- {
- $rules = [
- 'avatar' => 'sometimes|nullable|image',
- 'birth_date' => 'sometimes|nullable|date',
- 'document_number' => 'sometimes|nullable|string|max:20',
- 'gender' => 'sometimes|nullable|string|in:no_preference,male,female,other',
- 'email' => 'sometimes|nullable|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',
- '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',
- ];
- if ($this->isMethod('post')) {
- $rules['name'] = 'required|string|max:255';
- $rules['email'] = 'sometimes|nullable|email|unique:students,email';
- } else {
- $rules['name'] = 'sometimes|string|max:255';
- }
- return $rules;
- }
- }
|