diff --git a/models/ArticleLang.php b/models/ArticleLang.php index b5f092c..43b10cc 100755 --- a/models/ArticleLang.php +++ b/models/ArticleLang.php @@ -9,20 +9,21 @@ /** * This is the model class for table "blog_article_lang". + * - * @property integer $id +*@property integer $id * @property integer $blog_article_id * @property integer $language_id * @property string $title * @property string $body * @property string $body_preview - * @property string $alias * @property string $meta_title * @property string $meta_description * @property string $h1 * @property string $seo_text * @property Article $article * @property Language $language + * @property Alias $alias */ class ArticleLang extends ActiveRecord { @@ -156,6 +157,6 @@ */ public function getAlias() { - return $this->hasOne(Alias::className(), ['id' => 'alias_id']); + return $this->hasOne(Alias::className(), [ 'id' => 'alias_id' ]); } } diff --git a/models/ArticleSearch.php b/models/ArticleSearch.php index 3cb9330..ae53eb4 100755 --- a/models/ArticleSearch.php +++ b/models/ArticleSearch.php @@ -16,6 +16,8 @@ public $title; public $tag; + + public $category; /** * @inheritdoc @@ -40,6 +42,7 @@ [ 'title', 'tag', + 'category', ], 'string', ], @@ -77,6 +80,7 @@ [ 'lang', 'tags.lang', + 'categories.lang', ] ); @@ -131,6 +135,14 @@ $this->tag, ] ); + + $query->andFilterWhere( + [ + 'ilike', + 'blog_category_lang.title', + $this->category, + ] + ); return $dataProvider; } diff --git a/views/blog-article/index.php b/views/blog-article/index.php index 3f311cb..845bdf6 100755 --- a/views/blog-article/index.php +++ b/views/blog-article/index.php @@ -2,6 +2,7 @@ use artbox\weblog\models\Article; use artbox\weblog\models\ArticleSearch; + use artbox\weblog\models\Category; use artbox\weblog\models\Tag; use yii\data\ActiveDataProvider; use yii\helpers\ArrayHelper; @@ -44,8 +45,28 @@ 'value' => 'lang.title', ], [ + 'attribute' => 'category', + 'label' => \Yii::t('blog', 'Categories'), + 'value' => function (Article $model) { + if (empty($model->categories)) { + return \Yii::$app->formatter->asText(null); + } else { + return implode( + ',
', + ArrayHelper::getColumn( + $model->categories, + function (Category $category) { + return $category->lang->title; + } + ) + ); + } + }, + 'format' => 'html', + ], + [ 'attribute' => 'tag', - 'label' => \Yii::t('catalog', 'Tags'), + 'label' => \Yii::t('blog', 'Tags'), 'value' => function (Article $model) { if (empty($model->tags)) { return \Yii::$app->formatter->asText(null); -- libgit2 0.21.4