StudentResponsibleRequest.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Http\Requests;
  3. use App\Rules\AdultBirthDate;
  4. use App\ValueObjects\Cpf;
  5. use Illuminate\Foundation\Http\FormRequest;
  6. class StudentResponsibleRequest extends FormRequest
  7. {
  8. public function rules(): array
  9. {
  10. return [
  11. 'student_id' => 'required|exists:students,id',
  12. 'name' => 'required|string|max:255',
  13. 'birth_date' => ['required', 'date', new AdultBirthDate],
  14. 'cpf' => ['required', 'string', 'max:20', Cpf::rule()],
  15. 'gender' => 'nullable|string|in:male,female,other,no_preference',
  16. 'degree' => 'required|string|max:255',
  17. 'email' => 'required|email|max:255',
  18. 'phone' => 'required|string|max:20',
  19. 'street' => 'required|string|max:255',
  20. 'address_number' => 'nullable|string|max:20',
  21. 'postal_code' => 'required|string|max:10',
  22. 'neighborhood' => 'required|string|max:255',
  23. 'city_id' => 'required|exists:cities,id',
  24. 'state_id' => 'required|exists:states,id',
  25. 'complement' => 'nullable|string|max:255',
  26. 'notes' => 'nullable|string',
  27. ];
  28. }
  29. public function messages(): array
  30. {
  31. return [
  32. 'student_id.required' => 'O aluno é obrigatório.',
  33. 'student_id.exists' => 'Aluno não encontrado.',
  34. 'name.required' => 'O nome é obrigatório.',
  35. 'birth_date.required' => 'A data de nascimento é obrigatória.',
  36. 'cpf.required' => 'O CPF é obrigatório.',
  37. 'degree.required' => 'O grau de parentesco é obrigatório.',
  38. 'email.required' => 'O e-mail é obrigatório.',
  39. 'email.email' => 'Informe um e-mail válido.',
  40. 'phone.required' => 'O telefone é obrigatório.',
  41. 'street.required' => 'O endereço é obrigatório.',
  42. 'postal_code.required' => 'O CEP é obrigatório.',
  43. 'neighborhood.required' => 'O bairro é obrigatório.',
  44. 'city_id.required' => 'A cidade é obrigatória.',
  45. 'city_id.exists' => 'Cidade não encontrada.',
  46. 'state_id.required' => 'O estado é obrigatório.',
  47. 'state_id.exists' => 'Estado não encontrado.',
  48. ];
  49. }
  50. }