Download the PHP package cuongnd88/jutility without Composer
On this page you can find all versions of the php package cuongnd88/jutility. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package jutility
Laravel Japanese Utility
This package provides a convenient way to retrieve Japanese Utility such as Japanese Postal Code, Japanese Localization, CSV
Installation
1-Install cuongnd88/jutility
using Composer.
2-You can modify the configuration by copying it to your local config directory:
You select the utility by adding --tag
option:
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
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
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).
The JPostal provides functions to select a city correspond to a prefecture
JPostal.innerPrefecturesHtml(callback)
.
JPostal.nnerCityHtmlByPref(prefTag, callback)
.
JPostal Utility via PHP/Laravel
There are several functions to assist you get Japanese postal code:
_jpostal_pref($code = null)
: Get Japanese prefectures by code ._
_jpostal_pref_city($prefCode, $city = null)
: Get Japanese city by prefecture code ._
_jpostal_code($code)
: Get Japanese postal data by code ._
jlang($key)
: Use translation strings as keys are stored as JSON files in the resources/lang/{$currentLocale}/ directory .
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.
Language strings are stored in files within the resources/lang directory.
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:
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.
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 .
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 .
Demo
This is demo soure code.