Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ofcold/identity-card
A simple proof of identity card of the people's Republic of China.
https://github.com/ofcold/identity-card
codeigniter fuel id-card idcard identitycard laravel phalcon php71 symfony thinkphp yii
Last synced: 25 days ago
JSON representation
A simple proof of identity card of the people's Republic of China.
- Host: GitHub
- URL: https://github.com/ofcold/identity-card
- Owner: ofcold
- License: other
- Created: 2017-11-19T03:51:48.000Z (almost 7 years ago)
- Default Branch: 3.0
- Last Pushed: 2023-07-14T11:30:06.000Z (over 1 year ago)
- Last Synced: 2024-09-30T22:17:28.180Z (about 1 month ago)
- Topics: codeigniter, fuel, id-card, idcard, identitycard, laravel, phalcon, php71, symfony, thinkphp, yii
- Language: PHP
- Size: 317 KB
- Stars: 189
- Watchers: 5
- Forks: 32
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- laravel-awesome - ofcold/identity-card
README
[![996.icu](https://img.shields.io/badge/link-996.icu-red.svg?style=flat-square)](https://996.icu)
[![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg?style=flat-square)](https://github.com/996icu/996.ICU/blob/master/LICENSE)
![](https://img.shields.io/github/stars/ofcold/identity-card.svg?style=flat-square)
[![Total Downloads](https://poser.pugx.org/ofcold/identity-card/downloads?format=flat-square)](https://packagist.org/packages/ofcold/identity-card)China (region) citizen ID card tool
------------------------
Simplified Chinese Documentation
> China (Mainland) ID card package, the data from the national standard `GB/T 2260-2007` (People's Republic of China administrative divisions code standard).
## Other Language
- [.NET Rep](https://gitee.com/mick666/identity-card.NET)## Installing
```bash
composer require ofcold/identity-card
```## Instructions
A component based on People's Republic of China citizen ID card to obtain the user information.This works for any php framework, but only if the php version is greater than 7.1.## Useing
### Useing in Laravel Validation
> Multi-language add `Please enter a valid Id Card` to your json language package.
```php
use Ofcold\IdentityCard\Rules\IdCard;
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id_card' => [
'required',
new IdCard
]
];
}
```#### Verify your Chinese ID card
```php// Result false OR Ofcold\IdentityCard\IdentityCard instance.
$result = Ofcold\IdentityCard\IdentityCard::make('32010619831029081');if ( $result === false ) {
return 'Your ID number is incorrect';
}print_r($result->toArray());
```
#### OR test file.
```bash
php test
``````php
$idCard = Ofcold\IdentityCard\IdentityCard::make('320106198310290811', 'en');
// Use locale, Current supported zh-cn,en
// $idCard = Ofcold\IdentityCard\IdentityCard::make('320106198310290811', 'zh-cn');
if ( $idCard === false ) {return 'Your ID number is incorrect';
}
$area = $idCard->getArea();
$gender = $idCard->getGender();
$birthday = $idCard->getBirthday();
$age = $idCard->getAge();
$constellation = $idCard->getConstellation();
```#### Results:
```json
{
"area": "shan xi sheng yun cheng di qu yun cheng shi",
"province": "shan xi sheng",
"city": "yun cheng di qu",
"county": "yun cheng shi",
"gender": "Male",
"birthday": "1980-03-12",
"zodiac": "Pig",
"age": 38,
"constellation": "Pisces"
}
```### Api
- getArea() : string `Get Area`
- getConstellation() : string `Get constellation`
- getZodiac() : string `Get zodiac`
- getAge() : int `Get age`
- getBirthday(string $foramt = 'Y-m-d') : string `Get birthday`
- getGender() : string `Get gender`
- getCounty() : string|null `Get county`
- getCity() : string|null `Get city`
- getProvince() : string|null `Get province`
- toArray() : array `Get all information.`
- toJson(int $option) : string `Json format all information`
- __get() : mixed
- __toString() : toJson## CHANGELOG
### V3.0.0
- Added Laravel Rule.### V2.0.0
* Added [#2](https://github.com/ofcold/identity-card/pull/2) __get()
* Added [#2](https://github.com/ofcold/identity-card/pull/2) __toString()
* Modifed [#2](https://github.com/ofcold/identity-card/pull/2) static make() Method returns the current object or boolean type
* Removed [#2](https://github.com/ofcold/identity-card/pull/2) Construction method exception verification