public function actionIndex($category = null)
 {
     $query = News::find();
     if ($category !== null && !in_array($category, ['all', 'my'])) {
         $category = Category::find()->where(['slug' => $category])->one();
         if (!$category) {
             throw new NotFoundHttpException('Page not found.');
         }
         $query->andWhere(['category_id' => $category->id]);
     }
     if ($category === 'my') {
         if (Yii::$app->user->isGuest) {
             $this->redirect('/news');
         } else {
             $query->andWhere(['author_id' => Yii::$app->user->identity->id]);
         }
     }
     return $this->render('index', array('dataProvider' => $this->getDataProvider($query), 'category' => $category));
 }