Ejemplo n.º 1
0
 public function getAllLanguagesArray()
 {
     $languages = Languages::find()->multilingual()->all();
     foreach ($languages as $language) {
         $languagesArray[$language->id] = $language->name;
     }
     return $languagesArray;
 }
Ejemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Languages::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['language_id' => $this->language_id]);
     $query->andFilterWhere(['like', 'language_name', $this->language_name]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
 /**
  * Finds the Languages model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Languages the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Languages::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 4
0
 public function getLearningLanguages()
 {
     return $this->hasMany(\backend\models\Languages::className(), ['id' => 'language'])->viaTable('travellers_languages', ['traveller_id' => 'id'], function ($query) {
         return $query->where('travellers_languages.type = "learning"');
     });
 }
 /**
  * Finds the Languages model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Languages the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Languages::find()->multilingual()->andWhere(['id' => $id])->one()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }