|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Http\Requests\Employee; |
| 4 | + |
| 5 | +use Illuminate\Foundation\Http\FormRequest; |
| 6 | + |
| 7 | +class EmployeeRequest extends FormRequest |
| 8 | +{ |
| 9 | + /** |
| 10 | + * Get the validation rules that apply to the request. |
| 11 | + * |
| 12 | + * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> |
| 13 | + */ |
| 14 | + public function rules(): array |
| 15 | + { |
| 16 | + return [ |
| 17 | + // Account info |
| 18 | + 'name' => ['required', 'string', 'max:255', 'unique:users,name'], |
| 19 | + 'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email'], |
| 20 | + |
| 21 | + // Personal info |
| 22 | + 'first_name' => ['required', 'string', 'max:255'], |
| 23 | + 'last_name' => ['required', 'string', 'max:255'], |
| 24 | + 'gender' => ['required', 'string', 'max:50'], |
| 25 | + 'date_of_birth' => ['required', 'date'], |
| 26 | + 'phone_number' => ['required', 'string', 'max:20'], |
| 27 | + 'address' => ['required', 'string', 'max:255'], |
| 28 | + |
| 29 | + // Doctor specific info |
| 30 | + 'registration_number' => ['nullable', 'required_with:registration_origin,specialization,license_number,license_expiry_date', 'string', 'max:100'], |
| 31 | + 'registration_origin' => ['nullable', 'required_with:registration_number,specialization,license_number,license_expiry_date', 'string', 'max:255'], |
| 32 | + 'specialization' => ['nullable', 'required_with:registration_number,registration_origin,license_number,license_expiry_date', 'string', 'max:255'], |
| 33 | + 'license_number' => ['nullable', 'required_with:registration_number,registration_origin,specialization,license_expiry_date', 'string', 'max:100'], |
| 34 | + 'license_expiry_date' => ['nullable', 'required_with:registration_number,registration_origin,specialization,license_number', 'date', 'after:today'], |
| 35 | + |
| 36 | + // Employment info |
| 37 | + 'position' => ['required', 'string', 'max:100'], |
| 38 | + 'is_active' => ['required', 'boolean'], |
| 39 | + 'hire_date' => ['required', 'date'], |
| 40 | + 'termination_date' => ['nullable', 'date', 'after:hire_date'], |
| 41 | + ]; |
| 42 | + } |
| 43 | +} |
0 commit comments