1. Go to this page and download the library: Download life2016/yii2-region-custom 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/ */
life2016 / yii2-region-custom 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'=>\chenkby\region\RegionAction::className(),
'model'=>\app\models\Region::className()
];
return $actions;
}