fikrimastor / mykad
Mykad package is a laravel package, purposely to validate, parse, and format Malaysian Identity Card (MyKad) numbers.
Fund package maintenance!
FikriMastor
Installs: 1 210
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 2
Requires
- php: ^8.1
- nesbot/carbon: ^2.67
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
README
MyKad is a laravel package, purposely to validate, parse, extract and format Malaysian Identity Card (MyKad) numbers.
Installation
You can install the package via composer:
composer require fikrimastor/mykad
Optionally, you can publish the config file with:
php artisan vendor:publish --tag="mykad-config"
This is the contents of the published config file:
return [ 'states-code' => [ // Source: https://www.jpn.gov.my/my/kod-negeri // Johor '01' => 'Johor', '21' => 'Johor', '22' => 'Johor', '23' => 'Johor', '24' => 'Johor', // Kedah '02' => 'Kedah', '25' => 'Kedah', '26' => 'Kedah', '27' => 'Kedah', ... ... ... // Negeri Tidak Diketahui '82' => 'Unknown', ], ];
Usage
use FikriMastor\MyKad\Facades\MyKad; echo MyKad::sanitize('010101-01-0101'); // '010101010101' echo MyKad::extract('010101010101'); //[ // "date_of_birth" => "1 January 2001" // "state" => "Johor" // "gender" => "Male" //]
You can also use the validator to validate the MyKad number.
use FikriMastor\MyKad\Rules\IsMyKad; $request->validate([ 'mykad' => ['required', 'string', new IsMyKad], ]);
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.