Example #1
0
 public function init()
 {
     parent::init();
     $query = \app\models\CountryList::find()->with('countries', 'continents')->asArray()->all();
     if ($this->message === null) {
         $this->message = json_encode($query);
     } else {
         $this->message = 'Welcome dszfgsdf' . $this->message;
     }
 }
Example #2
0
 public function getCountryList()
 {
     return $this->hasMany(CountryList::className(), ['continents_code' => 'code']);
 }
 public function actionContinent_country($param = '')
 {
     $countriesStr = '';
     if ($_REQUEST["code"] != "") {
         $contylist = CountryList::find()->filterWhere(['country_list.continents_code' => $_REQUEST["code"]])->asArray()->all();
         if (count($contylist) > 0) {
             $ctr = 0;
             foreach ($contylist as $country) {
                 $countries = Countries::find()->filterWhere(['countries.code' => $country["countries_code"]])->asArray()->all();
                 if ($ctr == 0) {
                     $currency = $countries[0]['currency_code'];
                 }
                 $countriesStr .= "<option value='" . $countries[0]['code'] . "'>" . $countries[0]['name'] . "</option>";
                 $ctr++;
             }
         } else {
             $countriesStr = "<option>-</option>";
         }
     } else {
         $countriesStr = "<option>Select Country</option>";
         $currency = '';
     }
     $data = array("country" => $countriesStr, "currency" => $currency);
     echo json_encode($data);
 }
 /**
  * Finds the CountryList model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CountryList the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CountryList::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #5
0
 public function getCountryListCode()
 {
     return $this->hasOne(CountryList::className(), ['countries_code' => 'code']);
 }