Skip to content

Configuration ​

Publish the config file (optional):

bash
php artisan vendor:publish --tag="laravel-myanmar-nrc-config"
php
return [
    'locale' => 'en',
    'json_file' => null,
    'db_driven' => true,
    'cache' => [
        'enabled' => true,
        'store' => null,
        'key' => 'laravel-myanmar-nrc',
        'ttl' => null,
    ],
];
OptionDefaultDescription
localeenLanguage used when parsing: en or my. Only parse() reads it; isValid() and the validation rule ignore it
json_filenullNRC data file. null uses the bundled file. Use your own (e.g. storage_path('nrc.json')) and re-run php artisan mm-nrc:seed
db_driventrueValidate and parse against the database (true) or the JSON file (false). Can be overridden per call
cache.enabledtrueStore the NRC tables in a Laravel cache. false keeps them in memory only
cache.storenullCache store to use. null uses the default store
cache.keylaravel-myanmar-nrcCache key the tables are stored under
cache.ttlnullSeconds to keep the tables. null keeps them forever

A custom JSON file must contain a types array and a states array. Each state has a townships array. Every row has id, code, code_my, name and name_my.

Cache ​

The database backend reads the nrc_states, nrc_townships and nrc_types tables once, keeps them in memory for the rest of the process, and stores them in the configured cache so other requests and workers skip the queries. The JSON backend doesn't use the cache.

php artisan mm-nrc:seed clears the cache for you. After changing the tables any other way, clear it yourself:

bash
php artisan mm-nrc:clear-cache

Long-running workers

Octane and queue workers keep their in-memory copy of the tables until they restart, even after the cache is cleared. Restart them (php artisan octane:reload, php artisan queue:restart) after changing the NRC data.

Publish tags ​

TagPublishes
laravel-myanmar-nrc-configconfig/laravel-myanmar-nrc.php
laravel-myanmar-nrc-langlang/vendor/laravel-myanmar-nrc (validation messages in en and my)
laravel-myanmar-nrc-migrationsThe three NRC migrations into database/migrations, timestamped
laravel-myanmar-nrcAll of the above