1. Go to this page and download the library: Download yii-diandi/yii2-region 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/ */
yii-diandi / yii2-region example snippets
public static function getRegion($parentId=0)
{
$result = static::find()->where(['parent_id'=>$parentId])->asArray()->all();
return ArrayHelper::map($result, 'id', 'name');
}
public function actions()
{
$actions=parent::actions();
$actions['get-region']=[
'class'=>\diandi\region\RegionAction::className(),
'model'=>\app\models\Region::className()
];
return $actions;
}