├── .gitignore ├── LICENSE ├── README.md ├── composer.json ├── routes └── web.php └── src ├── Http └── Controllers │ └── IdValidatorController.php ├── IdValidator.php └── IdValidatorServiceProvider.php /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | phpunit.phar 3 | /vendor 4 | composer.phar 5 | composer.lock 6 | *.project 7 | .idea/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Jens Segers 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 身份证验证 2 | ====== 3 | 4 | 这个扩展基于[jxlwqq/id-validator](https://github.com/jxlwqq/id-validator),用来验证中国大陆居民身份证、港澳居民居住证以及台湾地区居民居住证,输入证件号码查询后,如果身份证号合法,下方会显示分析信息(地区、出生日期、星座、生肖、性别、校验位),如果不合法则下面显示一个异常提示 5 | 6 | ## 截图 7 | 8 |  9 | 10 | ## 安装 11 | 12 | ```bash 13 | composer require laravel-admin-ext/id-validator 14 | ``` 15 | 16 | 然后运行下面的命令在后台左侧菜单增加一个入口链接: 17 | ```bash 18 | php artisan admin:import id-validator 19 | ``` 20 | 21 | 打开`http://lcoalhost/admin/id-validator`即可使用。 22 | 23 | License 24 | ------------ 25 | Licensed under [The MIT License (MIT)](LICENSE). 26 | 27 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel-admin-ext/id-validator", 3 | "description": "一个中国居民身份证校验工具", 4 | "type": "library", 5 | "keywords": ["laravel-admin", "extension", "id-validator"], 6 | "homepage": "https://github.com/laravel-admin-ext/id-validator", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Song", 11 | "email": "zosong@126.com" 12 | } 13 | ], 14 | "require": { 15 | "php": ">=7.0.0", 16 | "encore/laravel-admin": "~1.6", 17 | "jxlwqq/id-validator": "*" 18 | }, 19 | "require-dev": { 20 | "phpunit/phpunit": "~6.0" 21 | }, 22 | "autoload": { 23 | "psr-4": { 24 | "Encore\\Admin\\IdValidator\\": "src/" 25 | } 26 | }, 27 | "extra": { 28 | "laravel": { 29 | "providers": [ 30 | "Encore\\Admin\\IdValidator\\IdValidatorServiceProvider" 31 | ] 32 | 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | header('身份证校验'); 20 | $content->description(' '); 21 | 22 | $form = new Form($request->all()); 23 | $form->method('GET'); 24 | $form->action(admin_url('id-validator')); 25 | $form->text('id', '身份证号码'); 26 | 27 | $content->row(new Box('查询', $form)); 28 | 29 | if ($id = $request->get('id')) { 30 | $content->row($this->renderResultTable($id)); 31 | } 32 | 33 | return $content; 34 | } 35 | 36 | protected function renderResultTable($id) 37 | { 38 | $idValidator = new IdValidator(); 39 | 40 | if (!$idValidator->isValid($id)) { 41 | $content = "