PHP code example of fikrimastor / mykad

1. Go to this page and download the library: Download fikrimastor/mykad library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fikrimastor / mykad example snippets


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',
    ],
];

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"
//]

use FikriMastor\MyKad\Rules\IsMyKad;
 
$request->validate([
    'mykad' => ['
bash
php artisan vendor:publish --tag="mykad-config"