From 99e2f4e7965e7792bdea15454039d0b9b243918a Mon Sep 17 00:00:00 2001 From: yarik Date: Fri, 3 Mar 2017 18:36:13 +0200 Subject: [PATCH] Category to purpose image --- backend/controllers/CategoryToPurposeController.php | 243 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ backend/views/category-to-purpose/_form.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ backend/views/category-to-purpose/_search.php | 31 +++++++++++++++++++++++++++++++ backend/views/category-to-purpose/create.php | 32 ++++++++++++++++++++++++++++++++ backend/views/category-to-purpose/index.php | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ backend/views/category-to-purpose/update.php | 40 ++++++++++++++++++++++++++++++++++++++++ backend/views/category-to-purpose/view.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ backend/views/layouts/main-sidebar.php | 8 +++++++- common/models/CategoryToPurpose.php | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/models/CategoryToPurposeSearch.php | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/translation/ru/app.php | 5 +++++ console/migrations/m170303_145834_add_category_to_purpose_table.php | 24 ++++++++++++++++++++++++ frontend/controllers/FilterController.php | 234 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------- frontend/views/filter/index.php | 33 +++++++++++++++++++++------------ 14 files changed, 904 insertions(+), 100 deletions(-) create mode 100755 backend/controllers/CategoryToPurposeController.php create mode 100644 backend/views/category-to-purpose/_form.php create mode 100644 backend/views/category-to-purpose/_search.php create mode 100644 backend/views/category-to-purpose/create.php create mode 100644 backend/views/category-to-purpose/index.php create mode 100644 backend/views/category-to-purpose/update.php create mode 100644 backend/views/category-to-purpose/view.php create mode 100644 common/models/CategoryToPurpose.php create mode 100644 common/models/CategoryToPurposeSearch.php create mode 100644 console/migrations/m170303_145834_add_category_to_purpose_table.php diff --git a/backend/controllers/CategoryToPurposeController.php b/backend/controllers/CategoryToPurposeController.php new file mode 100755 index 0000000..e094369 --- /dev/null +++ b/backend/controllers/CategoryToPurposeController.php @@ -0,0 +1,243 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], + ], + ]; + } + + /** + * Lists all CategoryToPurpose models. + * + * @return mixed + */ + public function actionIndex() + { + $searchModel = new CategoryToPurposeSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render( + 'index', + [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ] + ); + } + + /** + * Displays a single CategoryToPurpose model. + * + * @param integer $category_id + * @param integer $purpose_id + * + * @return mixed + */ + public function actionView($category_id, $purpose_id) + { + return $this->render( + 'view', + [ + 'model' => $this->findModel($category_id, $purpose_id), + ] + ); + } + + /** + * Creates a new CategoryToPurpose model. + * If creation is successful, the browser will be redirected to the 'view' page. + * + * @return mixed + */ + public function actionCreate() + { + $model = new CategoryToPurpose(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect( + [ + 'view', + 'category_id' => $model->category_id, + 'purpose_id' => $model->purpose_id, + ] + ); + } else { + + $language_id = Language::getDefaultLanguage()->language_id; + + $categories = Category::find() + ->innerJoinWith('lang') + ->select( + [ + 'category_lang.name', + 'category.category_id', + ] + ) + ->where([ 'category_lang.language_id' => $language_id ]) + ->indexBy('category_id') + ->column(); + $purposes = TaxOption::find() + ->innerJoinWith('taxGroup') + ->where( + [ + 'tax_group.tax_group_id' => 5, + 'level' => 0, + 'tax_option_lang.language_id' => $language_id, + ] + ) + ->joinWith('lang') + ->select( + [ + 'tax_option_lang.value', + 'tax_option.tax_option_id', + ] + ) + ->indexBy('tax_option_id') + ->column(); + + return $this->render( + 'create', + [ + 'model' => $model, + 'categories' => $categories, + 'purposes' => $purposes, + ] + ); + } + } + + /** + * Updates an existing CategoryToPurpose model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $category_id + * @param integer $purpose_id + * + * @return mixed + */ + public function actionUpdate($category_id, $purpose_id) + { + $model = $this->findModel($category_id, $purpose_id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect( + [ + 'view', + 'category_id' => $model->category_id, + 'purpose_id' => $model->purpose_id, + ] + ); + } else { + + $language_id = Language::getDefaultLanguage()->language_id; + + $categories = Category::find() + ->innerJoinWith('lang') + ->select( + [ + 'category_lang.name', + 'category.category_id', + ] + ) + ->where([ 'category_lang.language_id' => $language_id ]) + ->indexBy('category_id') + ->column(); + $purposes = TaxOption::find() + ->innerJoinWith('taxGroup') + ->where( + [ + 'tax_group.tax_group_id' => 5, + 'level' => 0, + 'tax_option_lang.language_id' => $language_id, + ] + ) + ->joinWith('lang') + ->select( + [ + 'tax_option_lang.value', + 'tax_option.tax_option_id', + ] + ) + ->indexBy('tax_option_id') + ->column(); + + return $this->render( + 'update', + [ + 'model' => $model, + 'categories' => $categories, + 'purposes' => $purposes, + ] + ); + } + } + + /** + * Deletes an existing CategoryToPurpose model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $category_id + * @param integer $purpose_id + * + * @return mixed + */ + public function actionDelete($category_id, $purpose_id) + { + $this->findModel($category_id, $purpose_id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Finds the CategoryToPurpose model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $category_id + * @param integer $purpose_id + * + * @return CategoryToPurpose the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($category_id, $purpose_id) + { + if (( $model = CategoryToPurpose::findOne( + [ + 'category_id' => $category_id, + 'purpose_id' => $purpose_id, + ] + ) ) !== null + ) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + } diff --git a/backend/views/category-to-purpose/_form.php b/backend/views/category-to-purpose/_form.php new file mode 100644 index 0000000..5e344ea --- /dev/null +++ b/backend/views/category-to-purpose/_form.php @@ -0,0 +1,64 @@ + + +
+ + [ 'enctype' => 'multipart/form-data' ] ]); ?> + + field($model, 'category_id') + ->dropDownList($categories) ?> + + field($model, 'purpose_id') + ->dropDownList($purposes) ?> + + field($model, 'image') + ->widget( + \kartik\file\FileInput::className(), + [ + 'language' => 'ru', + 'options' => [ + 'accept' => 'image/*', + 'multiple' => false, + ], + 'pluginOptions' => [ + 'allowedFileExtensions' => [ + 'jpg', + 'gif', + 'png', + ], + 'initialPreview' => !empty( $model->getImageUrl( + 0, + false + ) ) ? \common\components\artboximage\ArtboxImageHelper::getImage( + $model->imageUrl, + 'list' + ) : '', + 'overwriteInitial' => true, + 'showRemove' => false, + 'showUpload' => false, + 'previewFileType' => 'image', + ], + ] + ); ?> + +
+ isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] + ) ?> +
+ + + +
diff --git a/backend/views/category-to-purpose/_search.php b/backend/views/category-to-purpose/_search.php new file mode 100644 index 0000000..649a4ba --- /dev/null +++ b/backend/views/category-to-purpose/_search.php @@ -0,0 +1,31 @@ + + + diff --git a/backend/views/category-to-purpose/create.php b/backend/views/category-to-purpose/create.php new file mode 100644 index 0000000..32a9dd0 --- /dev/null +++ b/backend/views/category-to-purpose/create.php @@ -0,0 +1,32 @@ +title = Yii::t('app', 'Create Category To Purpose'); + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('app', 'Category To Purposes'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ +

title) ?>

+ + render( + '_form', + [ + 'model' => $model, + 'categories' => $categories, + 'purposes' => $purposes, + ] + ) ?> + +
diff --git a/backend/views/category-to-purpose/index.php b/backend/views/category-to-purpose/index.php new file mode 100644 index 0000000..e25504c --- /dev/null +++ b/backend/views/category-to-purpose/index.php @@ -0,0 +1,54 @@ +title = Yii::t('app', 'Category To Purposes'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ 'btn btn-success']) ?> +

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + [ + 'attribute' => 'category_id', + 'value' => function($model) { + /** + * @var CategoryToPurpose $model + */ + return $model->category->lang->name; + } + ], + [ + 'attribute' => 'purpose_id', + 'value' => function($model) { + /** + * @var CategoryToPurpose $model + */ + return $model->purpose->lang->value; + } + ], + [ + 'attribute' => 'image', + 'value' => 'imageUrl', + 'format' => 'image', + ], + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/backend/views/category-to-purpose/update.php b/backend/views/category-to-purpose/update.php new file mode 100644 index 0000000..eaf87fd --- /dev/null +++ b/backend/views/category-to-purpose/update.php @@ -0,0 +1,40 @@ +title = 'Обновить изображение '.$model->category->lang->name.' '.$model->purpose->lang->value; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('app', 'Category To Purposes'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->category->lang->name.' '.$model->purpose->lang->value, + 'url' => [ + 'view', + 'category_id' => $model->category_id, + 'purpose_id' => $model->purpose_id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update'); +?> +
+ +

title) ?>

+ + render( + '_form', + [ + 'model' => $model, + 'categories' => $categories, + 'purposes' => $purposes, + ] + ) ?> + +
diff --git a/backend/views/category-to-purpose/view.php b/backend/views/category-to-purpose/view.php new file mode 100644 index 0000000..194efef --- /dev/null +++ b/backend/views/category-to-purpose/view.php @@ -0,0 +1,47 @@ +title = $model->category->lang->name.' '.$model->purpose->lang->value; +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Category To Purposes'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->category_id, 'purpose_id' => $model->purpose_id], ['class' => 'btn btn-primary']) ?> + $model->category_id, 'purpose_id' => $model->purpose_id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + [ + 'attribute' => 'category_id', + 'value' => $model->category->lang->name, + ], + [ + 'attribute' => 'purpose_id', + 'value' => $model->purpose->lang->value, + ], + [ + 'attribute' => 'image', + 'value' => $model->imageUrl, + 'format' => 'image', + ], + ], + ]) ?> + +
diff --git a/backend/views/layouts/main-sidebar.php b/backend/views/layouts/main-sidebar.php index 07155e4..3b5ff70 100755 --- a/backend/views/layouts/main-sidebar.php +++ b/backend/views/layouts/main-sidebar.php @@ -50,7 +50,7 @@ use yii\widgets\Menu; 'label' => 'Категории', 'url' => ['/category'], 'options' => ['class'=>\Yii::$app->user->can('category') ? '' :'hide'], - 'active' => preg_match('/^category.*$/', $this->context->id), + 'active' => preg_match('/^category[\/.*]?$/', $this->context->id), ], [ 'label' => 'Бренды', @@ -87,6 +87,12 @@ use yii\widgets\Menu; 'url' => Url::toRoute(['/rubrication/tax-group', 'level'=> '1']), 'options' => ['class'=>\Yii::$app->user->can('rubrication') ? '' :'hide'], 'active' => preg_match('/^tax-group.*$/', $this->context->id) && (\Yii::$app->request->getQueryParam('level') == 1), + ], + [ + 'label' => 'Изображения категорий', + 'url' => Url::toRoute(['/category-to-purpose']), + 'options' => ['class'=>\Yii::$app->user->can('category-to-purpose') ? '' :'hide'], + 'active' => preg_match('/^category-to-purpose.*$/', $this->context->id), ] ] ], diff --git a/common/models/CategoryToPurpose.php b/common/models/CategoryToPurpose.php new file mode 100644 index 0000000..c1eb520 --- /dev/null +++ b/common/models/CategoryToPurpose.php @@ -0,0 +1,94 @@ + SaveImgBehavior::className(), + 'fields' => [ + [ + 'name' => 'image', + 'directory' => 'category_purpose', + ], + ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [['category_id', 'purpose_id'], 'required'], + [['category_id', 'purpose_id'], 'integer'], + [['image'], 'string', 'max' => 255], + [['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => Category::className(), 'targetAttribute' => ['category_id' => 'category_id']], + [['purpose_id'], 'exist', 'skipOnError' => true, 'targetClass' => TaxOption::className(), 'targetAttribute' => ['purpose_id' => 'tax_option_id']], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'category_id' => Yii::t('app', 'Category ID'), + 'purpose_id' => Yii::t('app', 'Purpose ID'), + 'image' => Yii::t('app', 'Image'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getCategory() + { + return $this->hasOne(Category::className(), ['category_id' => 'category_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getPurpose() + { + return $this->hasOne(TaxOption::className(), ['tax_option_id' => 'purpose_id']); + } +} diff --git a/common/models/CategoryToPurposeSearch.php b/common/models/CategoryToPurposeSearch.php new file mode 100644 index 0000000..58fa351 --- /dev/null +++ b/common/models/CategoryToPurposeSearch.php @@ -0,0 +1,95 @@ +joinWith('category.lang') + ->joinWith('purpose.lang'); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider( + [ + 'query' => $query, + ] + ); + + $dataProvider->setSort( + [ + 'attributes' => [ + 'category_id', + 'purpose_id', + ], + ] + ); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + + $query->andFilterWhere( + [ + 'like', + 'category_lang.name', + $this->category_id, + ] + ) + ->andFilterWhere( + [ + 'like', + 'tax_option_lang.value', + $this->purpose_id, + ] + ); + + return $dataProvider; + } + } diff --git a/common/translation/ru/app.php b/common/translation/ru/app.php index d4f1a8f..b1efca0 100755 --- a/common/translation/ru/app.php +++ b/common/translation/ru/app.php @@ -290,4 +290,9 @@ 'Value' => 'Значение', 'Articles ID' => 'ID статей', 'Article To Rating ID' => 'Article To Rating ID', + + 'Category To Purposes' => 'Изображения категорий по назначениям', + 'Create Category To Purpose' => 'Добавить изображение для категории по назначению', + 'Category ID' => 'Категория', + 'Purpose ID' => 'Назначение', ]; \ No newline at end of file diff --git a/console/migrations/m170303_145834_add_category_to_purpose_table.php b/console/migrations/m170303_145834_add_category_to_purpose_table.php new file mode 100644 index 0000000..c696573 --- /dev/null +++ b/console/migrations/m170303_145834_add_category_to_purpose_table.php @@ -0,0 +1,24 @@ +createTable('category_to_purpose', [ + 'category_id' => $this->integer()->notNull(), + 'purpose_id' => $this->integer()->notNull(), + 'image' => $this->string() + ]); + $this->addForeignKey('category_to_purpose_to_category', 'category_to_purpose', 'category_id', 'category', 'category_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('category_to_purpose_to_purpose', 'category_to_purpose', 'purpose_id', 'tax_option', 'tax_option_id', 'CASCADE', 'CASCADE'); + } + + public function down() + { + $this->dropForeignKey('category_to_purpose_to_category', 'category_to_purpose'); + $this->dropForeignKey('category_to_purpose_to_purpose', 'category_to_purpose'); + $this->dropTable('category_to_purpose'); + } +} diff --git a/frontend/controllers/FilterController.php b/frontend/controllers/FilterController.php index a300a97..efb81a2 100755 --- a/frontend/controllers/FilterController.php +++ b/frontend/controllers/FilterController.php @@ -2,6 +2,7 @@ namespace frontend\controllers; + use common\models\CategoryToPurpose; use common\modules\product\models\Brand; use common\modules\product\models\Category; use common\modules\product\models\ProductSearch; @@ -25,16 +26,36 @@ ->joinWith('products.lang') ->joinWith('products.categories.lang') ->joinWith('products.options.lang') - ->where([ - 'category.category_id' => $category->category_id, - 'tax_option.tax_option_id' => $purpose->tax_option_id, - ]) + ->where( + [ + 'category.category_id' => $category->category_id, + 'tax_option.tax_option_id' => $purpose->tax_option_id, + ] + ) ->all(); - return $this->render('index', [ - 'category' => $category, - 'purpose' => $purpose, - 'brands' => $brands, - ]); + $image = CategoryToPurpose::find() + ->where( + [ + 'category_id' => $category_id, + 'purpose_id' => $purpose_id, + ] + ) + ->andWhere( + [ + 'not', + [ 'image' => null ], + ] + ) + ->one(); + return $this->render( + 'index', + [ + 'category' => $category, + 'purpose' => $purpose, + 'brands' => $brands, + 'image' => $image, + ] + ); } /** @@ -48,46 +69,57 @@ $brandsAll = $category->activeBrands; $purposes = TaxOption::find() ->joinWith('lang', true, 'INNER JOIN') - ->joinWith([ - 'products' => function($query) use ($category) { - $query->joinWith([ - 'categories' => function($query) use ($category) { - $query->andWhere([ 'category.category_id' => $category->category_id ]); - }, - ]); - }, - ]) + ->joinWith( + [ + 'products' => function ($query) use ($category) { + $query->joinWith( + [ + 'categories' => function ($query) use ($category) { + $query->andWhere( + [ 'category.category_id' => $category->category_id ] + ); + }, + ] + ); + }, + ] + ) ->joinWith('products.categories.lang') ->joinWith('products.lang') ->joinWith('products.brand.lang') ->joinWith('taxGroup') - ->where([ - 'category.category_id' => $category->category_id, - 'tax_group.tax_group_id' => 5, - ]) + ->where( + [ + 'category.category_id' => $category->category_id, + 'tax_group.tax_group_id' => 5, + ] + ) ->all(); $brands = []; - foreach($purposes as $purpose) { + foreach ($purposes as $purpose) { /** * @var TaxOption $purpose */ $brands[ $purpose->tax_option_id ] = []; - foreach($purpose->products as $product) { + foreach ($purpose->products as $product) { /** * @var Brand $brand */ $brand = $product->brand; - if(!empty( $brand )) { + if (!empty( $brand )) { $brands[ $purpose->tax_option_id ][ $brand->brand_id ] = $brand; } } } - return $this->render('category', [ - 'category' => $category, - 'purposes' => $purposes, - 'brands' => $brands, - 'brandsAll' => $brandsAll, - ]); + return $this->render( + 'category', + [ + 'category' => $category, + 'purposes' => $purposes, + 'brands' => $brands, + 'brandsAll' => $brandsAll, + ] + ); } /** @@ -101,36 +133,45 @@ $categories = Category::find() ->joinWith('products.lang') ->joinWith('products.brand.lang') - ->joinWith([ - 'products' => function($query) use ($purpose) { - $query->joinWith([ - 'options' => function($query) use ($purpose) { - $query->andWhere([ 'tax_option.tax_option_id' => $purpose->tax_option_id ]); - }, - ]); - }, - ]) + ->joinWith( + [ + 'products' => function ($query) use ($purpose) { + $query->joinWith( + [ + 'options' => function ($query) use ($purpose) { + $query->andWhere( + [ 'tax_option.tax_option_id' => $purpose->tax_option_id ] + ); + }, + ] + ); + }, + ] + ) ->joinWith('products.options.lang') ->where([ 'tax_option.tax_option_id' => $purpose->tax_option_id ]) ->all(); $brands = []; - foreach($categories as $category) { + foreach ($categories as $category) { $brands[ $category->category_id ] = []; - foreach($category->products as $product) { + foreach ($category->products as $product) { /** * @var Brand $brand */ $brand = $product->brand; - if(!empty( $brand )) { + if (!empty( $brand )) { $brands[ $category->category_id ][ $brand->brand_id ] = $brand; } } } - return $this->render('purpose', [ - 'purpose' => $purpose, - 'categories' => $categories, - 'brands' => $brands, - ]); + return $this->render( + 'purpose', + [ + 'purpose' => $purpose, + 'categories' => $categories, + 'brands' => $brands, + ] + ); } public function actionBrand($category_id, $purpose_id, $brand_id) @@ -149,18 +190,23 @@ ->joinWith('brand.lang') ->joinWith('options.lang') ->joinWith('categories.lang') - ->andWhere([ - 'category.category_id' => $category->category_id, - 'tax_option.tax_option_id' => $purpose->tax_option_id, - 'brand.brand_id' => $brand->brand_id, - ]); - return $this->render('brand', [ - 'category' => $category, - 'purpose' => $purpose, - 'brand' => $brand, - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); + ->andWhere( + [ + 'category.category_id' => $category->category_id, + 'tax_option.tax_option_id' => $purpose->tax_option_id, + 'brand.brand_id' => $brand->brand_id, + ] + ); + return $this->render( + 'brand', + [ + 'category' => $category, + 'purpose' => $purpose, + 'brand' => $brand, + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ] + ); } public function actionCategoryBrand($category_id, $brand_id) @@ -177,26 +223,34 @@ $query->with('variants.lang') ->joinWith('brand.lang') ->joinWith('categories.lang') - ->andWhere([ - 'category.category_id' => $category->category_id, - 'brand.brand_id' => $brand->brand_id, - ]); - return $this->render('category-brand', [ - 'category' => $category, - 'brand' => $brand, - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); + ->andWhere( + [ + 'category.category_id' => $category->category_id, + 'brand.brand_id' => $brand->brand_id, + ] + ); + return $this->render( + 'category-brand', + [ + 'category' => $category, + 'brand' => $brand, + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ] + ); } public function actionCategoryBrands($category_id) { $category = $this->findCategory($category_id); $brands = $category->activeBrands; - return $this->render('category-brands', [ - 'category' => $category, - 'brands' => $brands, - ]); + return $this->render( + 'category-brands', + [ + 'category' => $category, + 'brands' => $brands, + ] + ); } /** @@ -209,12 +263,14 @@ { $model = TaxOption::find() ->joinWith('taxGroup') - ->where([ - 'tax_option.tax_option_id' => $id, - 'tax_group.tax_group_id' => 5, - ]) + ->where( + [ + 'tax_option.tax_option_id' => $id, + 'tax_group.tax_group_id' => 5, + ] + ) ->one(); - if(empty( $model )) { + if (empty( $model )) { throw new NotFoundHttpException(); } return $model; @@ -229,11 +285,13 @@ private function findCategory($id) { $model = Category::find() - ->where([ - 'category.category_id' => $id, - ]) + ->where( + [ + 'category.category_id' => $id, + ] + ) ->one(); - if(empty( $model )) { + if (empty( $model )) { throw new NotFoundHttpException(); } return $model; @@ -251,11 +309,13 @@ * @var Brand $model */ $model = Brand::find() - ->where([ - 'brand.brand_id' => $id, - ]) + ->where( + [ + 'brand.brand_id' => $id, + ] + ) ->one(); - if(empty( $model )) { + if (empty( $model )) { throw new NotFoundHttpException(); } return $model; diff --git a/frontend/views/filter/index.php b/frontend/views/filter/index.php index 2205a01..068ae41 100755 --- a/frontend/views/filter/index.php +++ b/frontend/views/filter/index.php @@ -1,11 +1,13 @@
getImageUrl(), 'full_filter'); + if($image) { + echo ArtboxImageHelper::getImage($image->imageUrl, 'full_filter'); + } else { + echo ArtboxImageHelper::getImage($category->getImageUrl(), 'full_filter'); + } ?>
@@ -48,13 +54,16 @@
-- libgit2 0.21.4