mhunesi / yii2-csc
Yii2 Country State City migration and models.
Installs: 15
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2025-03-15 09:14:29 UTC
README
Yii2 Country State City migration and models.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist mhunesi/yii2-csc "*"
or add
"mhunesi/yii2-csc": "*"
to the require section of your composer.json
file.
Usage
Once the extension is installed, simply use it in your code by :
And run migration:
'controllerMap' => [ 'migrate' => [ //.. 'migrationNamespaces' => [ //.. ], 'migrationPath' => [ //.. '@mhunesi/csc/migrations' ] ] ],
php yii migrate
OR
yii migrate --migrationPath=@mhunesi/csc/migrations
Models
- Country
- State
- City
use mhunesi\csc\models\Country; use mhunesi\csc\models\State; use mhunesi\csc\models\City; //Example 1 /** @var Country[] $country */ $country = Country::find()->all(); /** @var State[] $states */ $states = $country->states; foreach ($states as $state) { /** @var City[] $cities */ $cities = $state->cities } //Example 2 Country::find()->where(['iso2' => 'TR'])->one(); State::find()->where(['country_code' => 'TR'])->all();