|
|
@@ -5,26 +5,36 @@
|
|
|
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|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',
|
|
|
+ '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|exists:cities,id',
|
|
|
- 'state_id' => 'required|exists:states,id',
|
|
|
+ 'city_id' => 'required|integer|exists:cities,id',
|
|
|
+ 'state_id' => 'required|integer|exists:states,id',
|
|
|
'complement' => 'nullable|string|max:255',
|
|
|
'notes' => 'nullable|string',
|
|
|
];
|