protected function validator
(array $data) {
$general = GeneralSetting::first();
$password_validation = Password
::min(6); if ($general->secure_password) {
$password_validation = $password_validation->mixedCase()->numbers()->symbols()->uncompromised();
}
$agree = 'nullable';
if ($general->agree) {
$agree = 'required';
}
$countries = implode(',', array_column
($countryData, 'country'));
$validate = Validator::make($data, [
'firstname' => 'sometimes|required|string|max:50',
'lastname' => 'sometimes|required|string|max:50',
'email' => 'required|string|email|max:90|unique:users',
// 'mobile' => 'required|string|max:50|unique:users', // تم إزالته
'password' => ['required', $password_validation], // تم الإبقاء عليه دون التأكيد
'username' => 'required|alpha_num|unique:users|min:6',
'captcha' => 'sometimes|required',
// 'mobile_code' => 'required|in:'.$mobileCodes, // تم إزالته
// 'country_code' => 'required|in:'.$countryCodes, // تم إزالته
'country' => 'required|in:'.$countries,
'agree' => $agree
]);
return $validate;
}
cHJvdGVjdGVkIGZ1bmN0aW9uIHZhbGlkYXRvcihhcnJheSAkZGF0YSkKewogICAgJGdlbmVyYWwgPSBHZW5lcmFsU2V0dGluZzo6Zmlyc3QoKTsKICAgICRwYXNzd29yZF92YWxpZGF0aW9uID0gUGFzc3dvcmQ6Om1pbig2KTsKICAgIGlmICgkZ2VuZXJhbC0+c2VjdXJlX3Bhc3N3b3JkKSB7CiAgICAgICAgJHBhc3N3b3JkX3ZhbGlkYXRpb24gPSAkcGFzc3dvcmRfdmFsaWRhdGlvbi0+bWl4ZWRDYXNlKCktPm51bWJlcnMoKS0+c3ltYm9scygpLT51bmNvbXByb21pc2VkKCk7CiAgICB9CiAgICAkYWdyZWUgPSAnbnVsbGFibGUnOwogICAgaWYgKCRnZW5lcmFsLT5hZ3JlZSkgewogICAgICAgICRhZ3JlZSA9ICdyZXF1aXJlZCc7CiAgICB9CiAgICAkY291bnRyeURhdGEgPSAoYXJyYXkpanNvbl9kZWNvZGUoZmlsZV9nZXRfY29udGVudHMocmVzb3VyY2VfcGF0aCgndmlld3MvcGFydGlhbHMvY291bnRyeS5qc29uJykpKTsKICAgICRjb3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yeScgPT4gJ3JlcXVpcmVkfGluOicuJGNvdW50cmllcywKICAgICAgICAnYWdyZWUnID0+ICRhZ3JlZQogICAgXSk7CiAgICAKICAgIHJldHVybiAkdmFsaWRhdGU7Cn0K
protected function validator(array $data)
{
$general = GeneralSetting::first();
$password_validation = Password::min(6);
if ($general->secure_password) {
$password_validation = $password_validation->mixedCase()->numbers()->symbols()->uncompromised();
}
$agree = 'nullable';
if ($general->agree) {
$agree = 'required';
}
$countryData = (array)json_decode(file_get_contents(resource_path('views/partials/country.json')));
$countryCodes = implode(',', array_keys($countryData));
$countries = implode(',', array_column($countryData, 'country'));
$validate = Validator::make($data, [
'firstname' => 'sometimes|required|string|max:50',
'lastname' => 'sometimes|required|string|max:50',
'email' => 'required|string|email|max:90|unique:users',
// 'mobile' => 'required|string|max:50|unique:users', // تم إزالته
'password' => ['required', $password_validation], // تم الإبقاء عليه دون التأكيد
'username' => 'required|alpha_num|unique:users|min:6',
'captcha' => 'sometimes|required',
// 'mobile_code' => 'required|in:'.$mobileCodes, // تم إزالته
// 'country_code' => 'required|in:'.$countryCodes, // تم إزالته
'country' => 'required|in:'.$countries,
'agree' => $agree
]);
return $validate;
}