/**
  * Lists all I18nMessage models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new I18nMessageSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     Url::remember(Yii::$app->request->getUrl(), 'i18n-messages-filter');
     $languages = ArrayHelper::map(I18nMessage::find()->select('language')->distinct()->all(), 'language', 'language');
     $categories = ArrayHelper::map(I18nSourceMessage::find()->select('category')->distinct()->all(), 'category', 'category');
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'languages' => $languages, 'categories' => $categories]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = I18nSourceMessage::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['{{%i18n_source_message}}.id' => $this->id]);
     $query->andFilterWhere(['like', '{{%i18n_source_message}}.category', $this->category])->andFilterWhere(['like', '{{%i18n_source_message}}.message', $this->message]);
     return $dataProvider;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSourceMessageModel()
 {
     return $this->hasOne(I18nSourceMessage::className(), ['id' => 'id']);
 }
 /**
  * Finds the I18nSourceMessage model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return I18nSourceMessage the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = I18nSourceMessage::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }