From 45d40b65fe3bf3031b9368e999dc0fb755454620 Mon Sep 17 00:00:00 2001 From: dozer111 Date: Tue, 29 May 2018 13:51:48 +0300 Subject: [PATCH] 123 --- frontend/controllers/BlogController.php | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/frontend/controllers/BlogController.php b/frontend/controllers/BlogController.php index 1a1f944..d12af83 100755 --- a/frontend/controllers/BlogController.php +++ b/frontend/controllers/BlogController.php @@ -6,6 +6,7 @@ use common\models\blog\Category; use common\models\blog\Tag; use yii\data\ActiveDataProvider; + use yii\db\ActiveQuery; use yii\web\Controller; use yii\web\NotFoundHttpException; @@ -47,7 +48,9 @@ ) ->with( [ - 'categories.language', + 'categories' => function (ActiveQuery $query){ + $query->with('language')->where(['status' => true]); + }, ] ) @@ -123,7 +126,9 @@ ->where(['status' => true]) ->orderBy([ 'sort' => SORT_ASC ]) ->one(); - + if (empty($model)){ + throw new NotFoundHttpException(); + } $dataProvider = new ActiveDataProvider( [ 'query' => $model->getArticles() @@ -188,9 +193,15 @@ ->with( [ 'language', - 'categories.language', ] - ) + )->with( + [ + 'categories' => function (ActiveQuery $query){ + $query->with('language')->where(['status' => true]); + }, + ] + + ) ->where(['blog_article.status' => true]) ->orderBy( [ @@ -229,10 +240,16 @@ ->with( [ 'language', - 'categories.language', 'tags.language', ] - ) + )->with( + [ + 'categories' => function (ActiveQuery $query){ + $query->with('language')->where(['status' => true]); + }, + ] + + ) ->andWhere([ 'status' => true ]) ->one(); -- libgit2 0.21.4