| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace App\Http\Requests;
- use App\Rules\AdultBirthDate;
- use App\ValueObjects\Cpf;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Validation\Rule;
- class StudentResponsibleRequest extends FormRequest
- {
- public function rules(): array
- {
- return [
- 'student_id' => 'required|integer|exists:students,id',
- 'name' => 'required|string|max:255',
- 'birth_date' => ['required', 'date', new AdultBirthDate],
- 'cpf' => ['required', 'string', 'max:20', Cpf::rule()],
- 'gender' => 'nullable|string|in:male,female,other,no_preference',
- 'degree' => 'required|string|max:255',
- 'email' => [
- 'required',
- 'email',
- 'max:255',
- Rule::unique('student_responsibles', 'email')
- ->where(fn ($query) => $query->where('student_id', $this->input('student_id')))
- ->ignore($this->route('id')),
- ],
- 'phone' => 'required|string|max:20',
- 'street' => 'required|string|max:255',
- 'address_number' => 'nullable|string|max:20',
- 'postal_code' => 'required|string|max:10',
- 'neighborhood' => 'required|string|max:255',
- 'city_id' => 'required|integer|exists:cities,id',
- 'state_id' => 'required|integer|exists:states,id',
- 'complement' => 'nullable|string|max:255',
- 'notes' => 'nullable|string',
- ];
- }
- public function messages(): array
- {
- return [
- 'student_id.required' => 'O aluno é obrigatório.',
- 'student_id.exists' => 'Aluno não encontrado.',
- 'name.required' => 'O nome é obrigatório.',
- 'birth_date.required' => 'A data de nascimento é obrigatória.',
- 'cpf.required' => 'O CPF é obrigatório.',
- 'degree.required' => 'O grau de parentesco é obrigatório.',
- 'email.required' => 'O e-mail é obrigatório.',
- 'email.email' => 'Informe um e-mail válido.',
- 'phone.required' => 'O telefone é obrigatório.',
- 'street.required' => 'O endereço é obrigatório.',
- 'postal_code.required' => 'O CEP é obrigatório.',
- 'neighborhood.required' => 'O bairro é obrigatório.',
- 'city_id.required' => 'A cidade é obrigatória.',
- 'city_id.exists' => 'Cidade não encontrada.',
- 'state_id.required' => 'O estado é obrigatório.',
- 'state_id.exists' => 'Estado não encontrado.',
- ];
- }
- }
|