1. Go to this page and download the library: Download aoxiang/province-city-area 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/ */
aoxiang / province-city-area example snippets
namespace App\Http\Controllers;
use Aoxiang\Pca\ProvinceCityArea;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController{
public function getProvinceList()
{
return response()->json(ProvinceCityArea::getProvinceList());
}
public function getProvince()
{
return response()->json(ProvinceCityArea::getProvinceList());
}
public function getCity($provinceId)
{
if (empty($provinceId)) {
return response()->json([]);
}
return response()->json(ProvinceCityArea::getCityList($provinceId));
}
public function getArea($cityId)
{
if (empty($cityId)) {
return response()->json([]);
}
return response()->json(ProvinceCityArea::getAreaList($cityId));
}
public function getAllProvince()
{
return response()->json(ProvinceCityArea::getAllProvince());
}
public function getAllCity()
{
return response()->json(ProvinceCityArea::getAllCity());
}
public function getAllArea()
{
return response()->json(ProvinceCityArea::getAllArea());
}
public function getAllStreet()
{
return response()->json(ProvinceCityArea::getAllStreet());
}
public function test()
{
echo ProvinceCityArea::getName(21, 1827, 40847, 53114);
//echo "江西南昌市西湖区系马桩街道";
}
public function parseAddress()
{
$address = '江西省南昌市红谷滩双子塔A2-1888 敖翔 13866668888';
ProvinceCityArea::parseAddress($address);
}
}
php artisan migrate
php artisan pca:refreshData
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.