Commit 464eefe6 by 赵增煜
parents ec35417e 3976c6a2
......@@ -145,11 +145,9 @@ protected function form()
$status = $form->status;
$pharmacistNum = PharmacistModel::where('status', 1)->count();
if ($status == 1 && $pharmacistNum <= 0) {
return $form->response()->error('开启失败,至少启用一个药师才可以开启药店~');
return $form->response()->error('开启失败,至少添加并且启用一个药师才可以开启药店~');
}
if (! preg_match('/^1[3456789]{1}[0-9]{9}$/', $form->mobile)) {
$form->responseValidationMessages('mobile', '手机号格式错误~');
if ($form->mobile && ! preg_match('/^1[3456789]{1}[0-9]{9}$/', $form->mobile)) {
return $form->response()->error('手机号格式错误');
}
});
......
......@@ -8,6 +8,7 @@
use App\Models\PharmacyModel;
use App\Models\User;
use Illuminate\Http\Request;
use Jxlwqq\IdValidator\IdValidator;
// 问诊人控制器
class PatientController extends BaseApiController
......@@ -57,7 +58,8 @@ public function add(Request $request)
$patient->pharmacy_id = $pharmacy->id;
}
// 验证身份证格式
if (! validateIdCard($data['id_card'])) {
$idValidator = new IdValidator();
if (! $idValidator->isValid($data['id_card'])) {
return $this->failed('身份证格式错误');
}
$mobile = $data['mobile'];
......@@ -87,10 +89,10 @@ public function update(Request $request)
$id = $request->input('id');
$id_card = $request->input('id_card');
// 验证身份证格式
if (! validateIdCard($id_card)) {
$idValidator = new IdValidator();
if (! $idValidator->isValid($id_card)) {
return $this->failed('身份证格式错误');
}
$idCardInfo = Util::getIdCardInfo($id_card);
$data = PatientModel::find($id);
if (! $data) {
......
......@@ -165,39 +165,7 @@ function data_masking(string $str, string $strType)
}
}
if (! function_exists('validateIdCard')) {
/**
* 身份证号码校验
*/
function validateIdCard($value)
{
$len = strlen($value);
if ($len != 15 && $len != 18) {
return false;
}
if ($len === 18) {
$birthday = substr($value, 6, 8); // 6-14 出生日期
if (! validateBirthday($birthday)) {
return false;
}
$sex = substr($value, -2, 1);
if (! validateISO7064($value)) {
return false;
}
return true;
} else {
$birthday = substr($value, 6, 6);
$birthday = '19'.$birthday;
if (! validateBirthday($birthday)) {
return false;
}
$sex = substr($value, -1);
return true;
}
}
if (! function_exists('validateBirthday')) {
function validateBirthday($birthday)
{
$year = substr($birthday, 0, 4);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment