[ 'first_name' => 'required|min:3', 'last_name' => 'required|min:3', 'password' => ['required', 'confirmed', Password::min(8)], 'email' => ['required', 'email', 'unique:users,email'], 'birthdate' => 'required|date', 'gender' => ['required', Rule::in(['male', 'female'])], ], 'step2' => [ 'country' => 'nullable|min:2', 'city' => 'nullable|min:2', 'lang' => 'nullable|min:2', 'weight' => 'nullable|numeric', 'height' => 'nullable|numeric', ], 'step3' => [ 'chest_circumference' => 'nullable|numeric', 'waist_circumference' => 'nullable|numeric', 'hip_circumference' => 'nullable|numeric', ], 'step4' => [ 'blood_pressure_up' => 'nullable|numeric', 'blood_pressure_down' => 'nullable|numeric', 'has_hypo' => ['nullable', Rule::in([0, 1])], 'has_hyper' => ['nullable', Rule::in([0, 1])], ], 'step5' => ['about_alergy' => ['nullable', new MinWords(1)]], 'step6' => ['about_taking_pils' => ['nullable', new MinWords(1)]], 'step7' => ['about_sport_hobbies' => ['sometimes', 'nullable', new MinWords(1)]], 'step8' => [ 'favorite_foods' => ['nullable', new MinWords(1)], 'unfavorite_foods' => ['nullable', new MinWords(1)], ], 'step9' => ['additional_info' => ['nullable', new MinWords(1)]], ]; return $rules[$key]; } public static function getValidateData(string $key, object $obj): array { $data = [ 'step1' => [ 'first_name' => $obj->first_name, 'last_name' => $obj->last_name, 'email' => $obj->email, 'password' => $obj->password, 'password_confirmation' => $obj->password_confirmation, 'birthdate' => $obj->birthdate, 'gender' => $obj->gender, ], 'step2' => [ 'country' => $obj->country, 'city' => $obj->city, 'lang' => $obj->lang, 'weight' => static::transform($obj->weight), 'height' => static::transform($obj->height), ], 'step3' => [ 'chest_circumference' => $obj->chest_circumference, 'waist_circumference' => $obj->waist_circumference, 'hip_circumference' => $obj->hip_circumference, ], 'step4' => [ 'blood_pressure_up' => $obj->blood_pressure_up, 'blood_pressure_down' => $obj->blood_pressure_down, 'has_hypo' => $obj->has_hypo, 'has_hyper' => $obj->has_hyper, ], 'step5' => ['about_alergy' => $obj->about_alergy], 'step6' => ['about_taking_pils' => $obj->about_taking_pils], 'step7' => ['about_sport_hobbies' => $obj->about_sport_hobbies], 'step8' => [ 'favorite_foods' => $obj->favorite_foods, 'unfavorite_foods' => $obj->unfavorite_foods, ], 'step9' => ['additional_info' => $obj->additional_info], ]; return $data[$key]; } /** * Transform the given value. * * @param mixed $value * * @return mixed */ protected static function transform($value) { return trim($value) === '' ? null : $value; } }