Beispiel #1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getLocations()
 {
     return $this->hasMany(Location::className(), ['country_id' => 'iso_2']);
 }
Beispiel #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getLocations()
 {
     return $this->hasMany(Location::className(), ['city_id' => 'id']);
 }
Beispiel #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getLocation()
 {
     return $this->hasOne(Location::className(), ['id' => 'location_id']);
 }
 /**
  * 
  * Import Filename CSV must be provided in the following format:
  * 
  * [0]=> City Name
  * 
  * [1]=> Postal Code (Empty values will be threated as NULL)
  * 
  * [2]=> Country (iso-2 country code)
  * 
  * @param string $fn Absolute Path to Import Filename, if not set, the system will use a default import file loaded in the data folder in the root of the extension
  * @param type $delimiter
  * @return type
  */
 public function actionLocations($fn, $delimiter = ',')
 {
     $attributes = [0 => 'city', 1 => 'postcode', 2 => 'country_id'];
     $config = ['path' => $fn, 'delimeter' => $delimiter, 'saveModel' => Location::className(), 'attributeMap' => $attributes];
     return $this->importCSV($config);
 }