PHPackages                             cuongnd88/jutility - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. cuongnd88/jutility

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

cuongnd88/jutility
==================

Laravel Japanese Utility

1.4(4y ago)41831MITPHP

Since Jun 24Pushed 4y ago1 watchersCompare

[ Source](https://github.com/cuongnd88/jutility)[ Packagist](https://packagist.org/packages/cuongnd88/jutility)[ RSS](/packages/cuongnd88-jutility/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)DependenciesVersions (10)Used By (0)

Laravel Japanese Utility
========================

[](#laravel-japanese-utility)

This package provides a convenient way to retrieve Japanese Utility such as Japanese Postal Code, Japanese Localization, CSV

Installation
------------

[](#installation)

1-Install `cuongnd88/jutility` using Composer.

```
$ composer require cuongnd88/jutility
```

2-You can modify the configuration by copying it to your local config directory:

```
php artisan vendor:publish --provider="Cuongnd88\Jutility\JutilityServiceProvider"
```

You select the utility by adding `--tag` option:

```
php artisan vendor:publish --provider="Cuongnd88\Jutility\JutilityServiceProvider" --tag=public
```

There are 3 options:

*`--tag=public` is to publish the JPostal Utility via javascript.*

*`--tag=config` is to publish the JPostal Utility via php/laravel.*

*`--tag=lang` is to publish the Japanese Localization Utility.*

Sample Usage
------------

[](#sample-usage)

### JPostal Utility via Javascript

[](#jpostal-utility-via-javascript)

With the JPostal utility, you can achieve Japanese postal data by postal code. You just need implementing like below

`resources/views/user/jpostal.blade.php`

```
. . . .

        {{ __('Post code') }}

        {{ __('Info') }}

. . . .

    JPostal.init();

```

`JPostal.capture(zip, response)`:

*`zip` : is a string value that you can assign a value contains id or class sign in identifing zip code. For example: `.zip` or `#zip`.*

*`response` is a array or function that you get the data (prefecture, city, area and street). If the array only has one item, it resturns data with comma sign. The array has 4 elements, so it returns seperated data corresponding to prefecture, city, area and street. If the resposne is a function, it will callback .*

*`MEMO` you can use id and class signs for zip and response parameters. You can enter both postal code formats (NNN-NNNN or NNNNNNN).*

```

```

```

    JPostal.init();

    $( "#zip" ).keyup(function() {
        JPostal.capture('#zip', function(data){
            console.log(data);
        });
    });

```

The JPostal provides functions to select a city correspond to a prefecture

*`JPostal.innerPrefecturesHtml(callback)` .*

*`JPostal.nnerCityHtmlByPref(prefTag, callback)` .*

```
. . . .

        {{ __('Prefecture') }}

        {{ __('City') }}

. . . .

    JPostal.init();

    JPostal.innerPrefecturesHtml(function(prefectures){
        let selectTag = 'Prefecture';
        for (const [key, value] of Object.entries(prefectures)) {
            selectTag += `${value}`;
        }
        $('#selectPrefecture').append(selectTag);
    });

    $("#selectPrefecture").change(function(){
        JPostal.innerCityHtmlByPref('#selectPrefecture', function(cities){
            let selectTag = 'City';
            for (const item in cities) {
                const {id, name} = cities[item];
                selectTag += `${name}`;
            }
            $('#selectCity').append(selectTag);
        });
    });

```

### JPostal Utility via PHP/Laravel

[](#jpostal-utility-via-phplaravel)

There are several functions to assist you get Japanese postal code:

*`jpostal_pref($code = null)`: Get Japanese prefectures by code .*

```
dump(jpostal_pref(47));
```

*`jpostal_pref_city($prefCode, $city = null)`: Get Japanese city by prefecture code .*

```
dump(jpostal_pref_city(47));
dump(jpostal_pref_city(1, '01101));
```

*`jpostal_code($code)`: Get Japanese postal data by code .*

```
    dump(jpostal_code('1200000'));
    dump(jpostal_code('120-0000'));
```

*`jlang($key)`: Use translation strings as keys are stored as JSON files in the resources/lang/{$currentLocale}/ directory .*

```
    dump(jlang('Add Team Member'));
```

### Japanese Localization Utility

[](#japanese-localization-utility)

The `cuongnd88/jutility` package provides a convenient way to retrieve strings in Japanese languages. The default language for your application is stored in the `config/app.php` configuration file. You may modify this value to suit the needs of your application.

```
. . . .
    'locale' => 'ja',
. . . .
```

Language strings are stored in files within the resources/lang directory.

```
/resources
    /lang
        /en
            messages.php
        /ja
            messages.php
```

### CSV

[](#csv)

The CSV utility support to read, validate and get the CSV file. You have to set the valitor in `config/csv.php`. Please refer to the defaut:

```
return [
    /*
    |--------------------------------------------------------------------------
    | UTF-8 Bom
    |--------------------------------------------------------------------------
    |
    | The UTF-8 BOM is a sequence of bytes at the start of a text stream (0xEF, 0xBB, 0xBF)
    | that allows the reader to more reliably guess a file as being encoded in UTF-8.
    | Suitable for exporting Japanese data
    |
    */
    'utf-8-bom' => false,

    /*
    |--------------------------------------------------------------------------
    | Validator Support
    |--------------------------------------------------------------------------
    |
    | This is a sample defines how to validate CSV data:
    | - `user.header` is to identify the format of CSV file, that compare the standard header to the CSV header.
    | The "Invalid Header" message of Exception is threw if there is an error
    |
    | - `user.validator` is based on Laravel Validator. If you have multiple user tables or models you may configure multiple
    |       + `user.validator.rules`: set the Laravel validation rules
    |       + `user.validator.messages`: customize the Laravel default error messages
    |       + `user.validator.attributes`: customize the validation attributes
    */
    'user' => [
        'header' => [
            'fname' => 'First Name',
            'lname' => 'Last Name',
            'email' => 'Email',
        ],
        'validator' => [
            'rules' => [
                'fname' => 'required',
                'lname' => 'required',
                'email' => 'required|email',
            ],
            'messages' => [],
            'attributes' => [],
        ],
    ],
];
```

The `CSV` is a facade that provides access to an object from the container. You just need to import the `CSV` facade near the top of the file.

```
. . . .
use Cuongnd88\Jutility\Facades\CSV;

class UserController extends Controller
{
    . . . .
    public function postCSV(Request $request)
    {
        $csv = CSV::read(
                    $request->csv,
                    config('csv.user.header'),
                    config('csv.user.validator')
                )->filter();
        dump($csv);
    }
}
. . . .
```

*`read($file, array $standardHeader = [], $validatorConfig = null)`: read CSV file, return CSV object .*

*`filter()`: filter CSV data, return an array `['validated' => [...], 'error' => [...]]`.*

*`get()`: get CSV data (including validated and error data) except CSV header line, return an array.*

*`validatorErrors()`: get validated errors, return an array .*

```
    public function postCSV(Request $request)
    {
        $csv = CSV::read(
                    $request->csv,
                    config('csv.user.header'),
                    config('csv.user.validator')
                );
        $data = $csv->get();
        dump($data);
        $errorList = $csv->validatorErrors();
        dump($errorList);
    }
```

*`MEMO`: the CSV returns an array data (or error list), the index array is line number of CSV file.*

*`save(string $fileName, array $data, $header = null)`: export data to CSV file .*

```
    public function downloadCSV()
    {
        $data = User::all()->toArray();
        $header = ['ID','Fullname','Email','Mobile number', 'Email verified data time', 'Created date time', 'Updated date time'];
        CSV::save('user-data', $data, $header);
    }
```

Demo
----

[](#demo)

This is demo soure code.

[JPostal Utility](https://github.com/cuongnd88/lara-colab/blob/master/alpha/resources/views/user/jpostal.blade.php)

[CSV Utility](https://github.com/cuongnd88/lara-colab/blob/master/alpha/app/Http/Controllers/User/UserController.php)

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

9

Last Release

1770d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8dfc050aef777dd165bc3f60e724e4b53471854fcb3b522c103c936bd56e6643?d=identicon)[ngodinhcuong](/maintainers/ngodinhcuong)

---

Top Contributors

[![cuongnd-nta](https://avatars.githubusercontent.com/u/68364059?v=4)](https://github.com/cuongnd-nta "cuongnd-nta (16 commits)")

---

Tags

japan-postjapan-post-codejapan-zip-codejapanese-localizationlaravelmodule-patternphp

### Embed Badge

![Health badge](/badges/cuongnd88-jutility/health.svg)

```
[![Health](https://phpackages.com/badges/cuongnd88-jutility/health.svg)](https://phpackages.com/packages/cuongnd88-jutility)
```

###  Alternatives

[zservices/query

Pacote para consultas em serviços do governo.

131.1k](/packages/zservices-query)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
