public function actionIndex()
 {
     $language = Language::findOrDefault(Yii::$app->request->get('languageId'));
     $category = SourceMessage::find()->where(['category' => Yii::$app->request->get('categoryId')])->one();
     $message = SourceMessage::find();
     //        if(!empty($language)) {
     //            $message->with(['messages' => function($query) use($language) {
     //                $query->andWhere(['language' => $language->lang_id]);
     //            }]);
     //        }
     if (!empty($category)) {
         $message->where(['category' => $category->category]);
     }
     $messages_count = clone $message;
     $pages = new Pagination(['totalCount' => $messages_count->count(), 'defaultPageSize' => 50]);
     $messages = $message->offset($pages->offset)->orderBy(['id' => SORT_DESC])->limit($pages->limit)->all();
     return $this->render('index', ['allLanguages' => Language::find()->all(), 'languages' => Language::find()->where(['active' => true])->all(), 'allCategories' => SourceMessage::find()->select('category')->groupBy(['category'])->orderBy(['category' => SORT_ASC])->all(), 'sourceMessages' => $messages, 'pages' => $pages, 'addModel' => new SourceMessage(), 'selectedCategory' => !empty($category->category) ? $category->category : null, 'selectedLanguage' => $language]);
 }