Beispiel #1
0
 /**
  * Lists all LanguageTranslate models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new LanguageTranslateSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $languages = Language::getLanguages();
     $categories = ArrayHelper::map(LanguageSource::find()->select('category')->distinct()->all(), 'category', 'category');
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'languages' => $languages, 'categories' => $categories]);
 }
Beispiel #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = LanguageSource::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $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(['id' => $this->id]);
     $query->andFilterWhere(['like', 'category', $this->category])->andFilterWhere(['like', 'message', $this->message]);
     return $dataProvider;
 }
Beispiel #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSourceMessageModel()
 {
     return $this->hasOne(LanguageSource::className(), ['id' => 'id']);
 }
Beispiel #4
0
 /**
  * Finds the LanguageSource model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return LanguageSource the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = LanguageSource::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }