Commit 62633ca7 by lujunyi

身份证验证

parent cbb6a44b
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
use Dcat\Admin\Grid; use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController; use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Show; use Dcat\Admin\Show;
use Jxlwqq\IdValidator\IdValidator;
// 医师 // 医师
class DoctorController extends AdminController class DoctorController extends AdminController
...@@ -137,6 +138,16 @@ protected function form() ...@@ -137,6 +138,16 @@ protected function form()
$form->image('signed_pic')->accept('jpg,png,jpeg')->uniqueName()->autoUpload()->retainable()->removable(false); $form->image('signed_pic')->accept('jpg,png,jpeg')->uniqueName()->autoUpload()->retainable()->removable(false);
}); });
$form->saving(function (Form $form) {
if ($form->mobile && ! preg_match('/^1[3456789]{1}[0-9]{9}$/', $form->mobile)) {
return $form->response()->error('手机号格式错误');
}
$idValidator = new IdValidator();
if ($form->id_card && ! $idValidator->isValid($form->id_card)) {
return $form->response()->error('身份证格式错误');
}
});
// 右上角按钮控制 // 右上角按钮控制
$form->disableDeleteButton(); // 去掉删除按钮 $form->disableDeleteButton(); // 去掉删除按钮
$form->disableViewButton(); // 去掉跳转详情页按钮 $form->disableViewButton(); // 去掉跳转详情页按钮
......
...@@ -97,13 +97,23 @@ protected function form() ...@@ -97,13 +97,23 @@ protected function form()
$form->display('id')->width(4); $form->display('id')->width(4);
$form->text('name')->width(4)->required()->maxLength(32, '最多输入32个字符'); $form->text('name')->width(4)->required()->maxLength(32, '最多输入32个字符');
$form->text('id_card')->width(4)->required()->maxLength(18, '最多输入18个字符'); $form->text('id_card')->width(4)->required()->maxLength(18, '最多输入18个字符');
$form->mobile('mobile')->width(4)->required()->rules('required|regex:/^1[3456789]\d{9}$/'); $form->mobile('mobile')->width(4)->required();
$form->display('user_id')->width(4); $form->display('user_id')->width(4);
$form->select('pharmacy_id')->options(PharmacyModel::all()->pluck('name', 'id'))->disable()->width(4); $form->select('pharmacy_id')->options(PharmacyModel::all()->pluck('name', 'id'))->disable()->width(4);
$form->display('created_at')->width(4); $form->display('created_at')->width(4);
$form->display('updated_at')->width(4); $form->display('updated_at')->width(4);
$form->saving(function (Form $form) {
if ($form->mobile && ! preg_match('/^1[3456789]{1}[0-9]{9}$/', $form->mobile)) {
return $form->response()->error('手机号格式错误');
}
$idValidator = new IdValidator();
if ($form->id_card && ! $idValidator->isValid($form->id_card)) {
return $form->response()->error('身份证格式错误');
}
});
// 右上角按钮控制 // 右上角按钮控制
$form->disableDeleteButton(); // 去掉删除按钮 $form->disableDeleteButton(); // 去掉删除按钮
$form->disableViewButton(); // 去掉跳转详情页按钮 $form->disableViewButton(); // 去掉跳转详情页按钮
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
use Dcat\Admin\Show; use Dcat\Admin\Show;
use Dcat\Admin\Widgets\Tab; use Dcat\Admin\Widgets\Tab;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Jxlwqq\IdValidator\IdValidator;
// 药师 // 药师
class PharmacistController extends AdminController class PharmacistController extends AdminController
...@@ -162,6 +163,16 @@ protected function form() ...@@ -162,6 +163,16 @@ protected function form()
$form->image('signed_pic')->accept('jpg,png,jpeg')->uniqueName()->autoUpload()->retainable()->removable(false); $form->image('signed_pic')->accept('jpg,png,jpeg')->uniqueName()->autoUpload()->retainable()->removable(false);
}); });
$form->saving(function (Form $form) {
if ($form->mobile && ! preg_match('/^1[3456789]{1}[0-9]{9}$/', $form->mobile)) {
return $form->response()->error('手机号格式错误');
}
$idValidator = new IdValidator();
if ($form->id_card && ! $idValidator->isValid($form->id_card)) {
return $form->response()->error('身份证格式错误');
}
});
// 右上角按钮控制 // 右上角按钮控制
$form->disableDeleteButton(); // 去掉删除按钮 $form->disableDeleteButton(); // 去掉删除按钮
$form->disableViewButton(); // 去掉跳转详情页按钮 $form->disableViewButton(); // 去掉跳转详情页按钮
......
...@@ -147,7 +147,11 @@ protected function form() ...@@ -147,7 +147,11 @@ protected function form()
if ($status == 1 && $pharmacistNum <= 0) { 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', '手机号格式错误~');
return $form->response()->error('手机号格式错误');
}
}); });
$form->saved(function (Form $form, $result) { $form->saved(function (Form $form, $result) {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"dcat/laravel-wherehasin": "^0.8.0", "dcat/laravel-wherehasin": "^0.8.0",
"guzzlehttp/guzzle": "^7.2", "guzzlehttp/guzzle": "^7.2",
"intervention/image-laravel": "^1.3", "intervention/image-laravel": "^1.3",
"jxlwqq/id-validator": "^1.4",
"laravel/framework": "^10.10", "laravel/framework": "^10.10",
"laravel/helpers": "^1.6", "laravel/helpers": "^1.6",
"laravel/sanctum": "^3.3", "laravel/sanctum": "^3.3",
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "f74c8b7d5c6db43a23465bc7a3db87e4", "content-hash": "dc518d1fd55a42b2a5b3d748a4dc1d94",
"packages": [ "packages": [
{ {
"name": "box/spout", "name": "box/spout",
...@@ -1937,6 +1937,50 @@ ...@@ -1937,6 +1937,50 @@
"time": "2024-06-15T08:20:20+00:00" "time": "2024-06-15T08:20:20+00:00"
}, },
{ {
"name": "jxlwqq/id-validator",
"version": "1.4.33",
"source": {
"type": "git",
"url": "https://github.com/jxlwqq/id-validator.git",
"reference": "2884acaebc6149aeeb4444a90afad8614135f577"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jxlwqq/id-validator/zipball/2884acaebc6149aeeb4444a90afad8614135f577",
"reference": "2884acaebc6149aeeb4444a90afad8614135f577",
"shasum": ""
},
"require": {
"php": ">=5.6.0"
},
"require-dev": {
"phpunit/phpunit": ">=5.6"
},
"type": "library",
"autoload": {
"psr-4": {
"Jxlwqq\\IdValidator\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "jxlwqq",
"email": "jxlwqq@gmail.com",
"homepage": "https://jxlwqq.github.io"
}
],
"description": "Chinese Mainland Personal ID Card Validation",
"support": {
"issues": "https://github.com/jxlwqq/id-validator/issues",
"source": "https://github.com/jxlwqq/id-validator/tree/1.4.33"
},
"time": "2021-12-10T06:39:36+00:00"
},
{
"name": "laravel/framework", "name": "laravel/framework",
"version": "v10.48.23", "version": "v10.48.23",
"source": { "source": {
......
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