/**
  * @inheritdoc
  */
 public function search($params)
 {
     $query = Message::find()->joinWith(['sourceMessage' => function ($query) {
         $query->from(['sourceMessage' => SourceMessage::tableName()]);
     }]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if ($this->language) {
         $query->filterWhere(['language' => $this->language]);
     }
     if ($this->prefix) {
         $query->andFilterWhere(['or', ['like', 'sourceMessage.category', $this->prefix . '.'], ['like', 'sourceMessage.category', $this->prefix . '/']]);
     }
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'translation', $this->translation])->andFilterWhere(['like', 'sourceMessage.message', $this->source]);
     if ($this->category) {
         if ($this->prefix) {
             $query->andFilterWhere(['or', ['like', 'sourceMessage.category', $this->prefix . '.' . $this->category], ['like', 'sourceMessage.category', $this->prefix . '/' . $this->category]]);
         } else {
             $query->andFilterWhere(['like', 'sourceMessage.category', $this->category]);
         }
     }
     if ($this->translationStatus === static::MESSAGE_TRANSLATED_YES) {
         $query->andWhere('translation IS NOT NULL AND translation <> ""');
     } elseif ($this->translationStatus === static::MESSAGE_TRANSLATED_NO) {
         $query->andWhere('translation IS NULL OR translation = ""');
     }
     return $dataProvider;
 }
 public function actionFlush()
 {
     $tableNames = [Message::tableName(), SourceMessage::tableName()];
     $db = Yii::$app->getDb();
     foreach ($tableNames as $tableName) {
         $db->createCommand()->delete($tableName)->execute();
     }
     echo PHP_EOL . 'Done.' . PHP_EOL;
 }