Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵增煜
/
tzt-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
79a6914f
authored
Nov 21, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
身份证验证
parent
11c26861
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
36 deletions
+6
-36
app/Api/Controllers/PatientController.php
+5
-3
app/helpers.php
+1
-33
No files found.
app/Api/Controllers/PatientController.php
View file @
79a6914f
...
...
@@ -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
)
{
...
...
app/helpers.php
View file @
79a6914f
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment