承接 ofcold/identity-card 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ofcold/identity-card

最新稳定版本:3.3.2

Composer 安装命令:

composer require ofcold/identity-card

包简介

A simple proof of identity card of the people's Republic of China.

README 文档

README

996.icu LICENSE Total Downloads

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

Installing

    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.

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

    // 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.

    php test
$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:

{
    "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 __get()
  • Added #2 __toString()
  • Modifed #2 static make() Method returns the current object or boolean type
  • Removed #2 Construction method exception verification

统计信息

  • 总下载量: 38.64k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 190
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 189
  • Watchers: 4
  • Forks: 30
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-05-18