= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
diff --git a/backend/views/brand/_form.php b/backend/views/brand/_form.php
index 6ae3467..7c4530d 100755
--- a/backend/views/brand/_form.php
+++ b/backend/views/brand/_form.php
@@ -43,6 +43,8 @@ use yii\widgets\ActiveForm;
= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?>
+ = $form->field($model, 'in_menu')->checkbox()?>
+
= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
isNewRecord) :?>
diff --git a/backend/views/brand/index.php b/backend/views/brand/index.php
index d1295f1..ad78276 100755
--- a/backend/views/brand/index.php
+++ b/backend/views/brand/index.php
@@ -1,5 +1,6 @@
params['breadcrumbs'][] = $this->title;
'name',
'alias',
[
- 'attribute' => 'title',
- 'format' => 'html',
+ 'attribute' => 'image',
+ 'format' => 'image',
'value' => function($data) {
- return Html::img($data->imageUrl, ['width'=>'100']);
+ return ArtboxImageHelper::getImageSrc($data->imageUrl, 'brand_item');
},
],
diff --git a/backend/views/customer/_form.php b/backend/views/customer/_form.php
index 01f70af..1170648 100755
--- a/backend/views/customer/_form.php
+++ b/backend/views/customer/_form.php
@@ -12,11 +12,10 @@ use yii\widgets\ActiveForm;
- = $form->field($model, 'id')->textInput() ?>
= $form->field($model, 'username')->textInput(['maxlength' => true]) ?>
- = $form->field($model, 'password')->passwordInput(['maxlength' => true]) ?>
+
= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
@@ -26,8 +25,6 @@ use yii\widgets\ActiveForm;
= $form->field($model, 'date_time')->textInput() ?>
- = $form->field($model, 'sex')->textInput(['maxlength' => true]) ?>
-
= $form->field($model, 'birth_day')->textInput() ?>
= $form->field($model, 'birth_month')->textInput() ?>
diff --git a/backend/views/customer/index.php b/backend/views/customer/index.php
index b7e25bf..40909ae 100755
--- a/backend/views/customer/index.php
+++ b/backend/views/customer/index.php
@@ -26,7 +26,6 @@ $this->params['breadcrumbs'][] = $this->title;
'id',
'username',
- 'password',
'name',
'surname',
// 'phone',
diff --git a/backend/views/slider-image/_form.php b/backend/views/slider-image/_form.php
index 52b2954..01f72be 100755
--- a/backend/views/slider-image/_form.php
+++ b/backend/views/slider-image/_form.php
@@ -16,6 +16,7 @@ use yii\widgets\ActiveForm;
['enctype' => 'multipart/form-data']]); ?>
+
= $form->field($model, 'image')->widget(\kartik\file\FileInput::classname(), [
'model' => $model,
'attribute' => 'image',
diff --git a/common/behaviors/SaveImgBehavior.php b/common/behaviors/SaveImgBehavior.php
new file mode 100644
index 0000000..2c16501
--- /dev/null
+++ b/common/behaviors/SaveImgBehavior.php
@@ -0,0 +1,83 @@
+ 'beforeUpdate',
+ ActiveRecord::EVENT_BEFORE_INSERT => 'beforeInsert',
+ ];
+ }
+
+ public function beforeUpdate($event)
+ {
+
+
+ if ( ($image = UploadedFile::getInstance($this->owner, 'image')) ) {
+ $this->owner->image = $image->name;
+ }
+
+ if(!$this->owner->image){
+ $this->owner->image = $this->owner->getOldAttribute('image');
+ }
+
+
+ if ($image) {
+ $imgDir = \Yii::getAlias('@storage/'.$this->directory.'/');
+
+ if(!is_dir($imgDir)) {
+ mkdir($imgDir, 0755, true);
+ }
+
+ $image->saveAs(\Yii::getAlias('@storage/'.$this->directory.'/' . $image->name));
+ }
+ }
+
+
+ public function beforeInsert($event)
+ {
+
+
+ if ( ($image = UploadedFile::getInstance($this->owner, 'image')) ) {
+ $this->owner->image = $image->name;
+ }
+
+
+
+ if ($image) {
+ $imgDir = \Yii::getAlias('@storage/'.$this->directory.'/');
+
+ if(!is_dir($imgDir)) {
+ mkdir($imgDir, 0755, true);
+ }
+
+ $image->saveAs(\Yii::getAlias('@storage/'.$this->directory.'/' . $image->name));
+ }
+ }
+
+
+
+ public function getImageFile() {
+ return empty($this->owner->image) ? null : '/storage/'.$this->directory.'/'. $this->owner->image;
+ }
+
+ public function getImageUrl() {
+ return empty($this->owner->image) ? null : '/storage/'.$this->directory.'/'. $this->owner->image;
+ }
+}
\ No newline at end of file
diff --git a/common/config/main.php b/common/config/main.php
index 5a3ace9..c386e57 100755
--- a/common/config/main.php
+++ b/common/config/main.php
@@ -119,15 +119,11 @@ return [
],
'brand_item' => [
'resize' => [
- 'width' => 150,
- 'height' => 150,
- 'master' => null
- ],
- 'crop' => [
- 'width' => 150,
- 'height' => 150,
+ 'width' => 125,
+ 'height' => 54,
'master' => null
],
+
],
'mainmenu' => [
'resize' => [
diff --git a/common/models/Articles.php b/common/models/Articles.php
index 06b7ac8..bc99142 100755
--- a/common/models/Articles.php
+++ b/common/models/Articles.php
@@ -3,6 +3,7 @@
namespace common\models;
use common\behaviors\RatingBehavior;
+use common\behaviors\SaveImgBehavior;
use common\modules\comment\models\CommentModel;
use Yii;
@@ -33,12 +34,18 @@ class Articles extends \yii\db\ActiveRecord
return 'articles';
}
+
+
/**
* @inheritdoc
*/
public function behaviors()
{
return [
+ [
+ 'class' => SaveImgBehavior::className(),
+ 'directory' => 'articles'
+ ],
'slug' => [
'class' => 'common\behaviors\Slug',
'in_attribute' => 'title',
@@ -84,15 +91,6 @@ class Articles extends \yii\db\ActiveRecord
];
}
- public function getImageFile() {
- return empty($this->image) ? null : Yii::getAlias('@imagesDir/articles/'. $this->image);
- }
-
- public function getImageUrl()
- {
- return empty($this->image) ? null : Yii::getAlias('@imagesUrl/articles/' . $this->image);
- }
-
public function recalculateRating() {
/**
* @var ArticleToRating $averageRating
diff --git a/common/models/Banner.php b/common/models/Banner.php
index 4638770..da6de11 100755
--- a/common/models/Banner.php
+++ b/common/models/Banner.php
@@ -2,6 +2,7 @@
namespace common\models;
+use common\behaviors\SaveImgBehavior;
use Yii;
/**
@@ -26,6 +27,21 @@ class Banner extends \yii\db\ActiveRecord
return 'banner';
}
+
+
+ /**
+ * @inheritdoc
+ */
+ public function behaviors()
+ {
+ return [
+ [
+ 'class' => SaveImgBehavior::className(),
+ 'directory' => 'banner'
+ ],
+ ];
+ }
+
/**
* @inheritdoc
*/
diff --git a/common/models/Bg.php b/common/models/Bg.php
index aabd040..405ad39 100755
--- a/common/models/Bg.php
+++ b/common/models/Bg.php
@@ -2,6 +2,8 @@
namespace common\models;
+use common\behaviors\SaveImgBehavior;
+
class Bg extends \yii\db\ActiveRecord
{
public $old_image;
@@ -10,7 +12,20 @@ class Bg extends \yii\db\ActiveRecord
{
return 'bg';
}
-
+
+ /**
+ * @inheritdoc
+ */
+ public function behaviors()
+ {
+ return [
+ [
+ 'class' => SaveImgBehavior::className(),
+ 'directory' => 'bg'
+ ],
+ ];
+ }
+
public function rules()
{
return [
diff --git a/common/models/Customer.php b/common/models/Customer.php
index 8cb51e4..d64fd12 100644
--- a/common/models/Customer.php
+++ b/common/models/Customer.php
@@ -88,30 +88,6 @@ class Customer extends User implements \yii\web\IdentityInterface
/**
* @return \yii\db\ActiveQuery
*/
- public function getArtboxComments()
- {
- return $this->hasMany(ArtboxComment::className(), ['user_id' => 'id']);
- }
-
- /**
- * @return \yii\db\ActiveQuery
- */
- public function getArtboxCommentRatings()
- {
- return $this->hasMany(ArtboxCommentRating::className(), ['user_id' => 'id']);
- }
-
- /**
- * @return \yii\db\ActiveQuery
- */
- public function getArtboxLikes()
- {
- return $this->hasMany(ArtboxLike::className(), ['user_id' => 'id']);
- }
-
- /**
- * @return \yii\db\ActiveQuery
- */
public function getShares()
{
return $this->hasMany(Share::className(), ['user_id' => 'id']);
diff --git a/common/models/CustomerSearch.php b/common/models/CustomerSearch.php
index 9cd6feb..ab3b5d2 100755
--- a/common/models/CustomerSearch.php
+++ b/common/models/CustomerSearch.php
@@ -18,8 +18,12 @@ class CustomerSearch extends Customer
public function rules()
{
return [
- [['id', 'birth_day', 'birth_month', 'birth_year', 'group_id'], 'integer'],
- [['username', 'password', 'name', 'surname', 'phone', 'date_time', 'sex', 'body'], 'safe'],
+ [['date_time'], 'safe'],
+ [['birth_day', 'birth_month', 'birth_year', 'group_id', 'status', 'created_at', 'updated_at'], 'integer'],
+ [['body'], 'string'],
+ [['status'],'default', 'value' => '10'],
+ [['username', 'name', 'surname', 'phone', 'email', 'password_reset_token','username', 'password_hash'], 'string', 'max' => 255],
+ [['gender', 'auth_key'], 'string', 'max' => 32],
];
}
@@ -68,11 +72,9 @@ class CustomerSearch extends Customer
]);
$query->andFilterWhere(['like', 'username', $this->username])
- ->andFilterWhere(['like', 'password', $this->password])
->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'surname', $this->surname])
->andFilterWhere(['like', 'phone', $this->phone])
- ->andFilterWhere(['like', 'sex', $this->sex])
->andFilterWhere(['like', 'body', $this->body]);
return $dataProvider;
diff --git a/common/models/SliderImage.php b/common/models/SliderImage.php
index b24fa3c..e54c941 100755
--- a/common/models/SliderImage.php
+++ b/common/models/SliderImage.php
@@ -2,6 +2,7 @@
namespace common\models;
+use common\behaviors\SaveImgBehavior;
use Yii;
/**
@@ -20,6 +21,23 @@ use Yii;
*/
class SliderImage extends \yii\db\ActiveRecord
{
+
+
+
+ /**
+ * @inheritdoc
+ */
+ public function behaviors()
+ {
+ return [
+ [
+ 'class' => SaveImgBehavior::className(),
+ 'directory' => 'slider'
+ ]
+ ];
+ }
+
+
/**
* @inheritdoc
*/
@@ -57,6 +75,8 @@ class SliderImage extends \yii\db\ActiveRecord
];
}
+
+
/**
* @return \yii\db\ActiveQuery
*/
@@ -65,12 +85,6 @@ class SliderImage extends \yii\db\ActiveRecord
return $this->hasOne(Slider::className(), ['slider_id' => 'slider_id']);
}
- public function getImageFile() {
- return empty($this->image) ? null : '/storage/slider/'. $this->image;
- }
- public function getImageUrl() {
- return empty($this->image) ? null : '/storage/slider/'. $this->image;
- }
}
diff --git a/common/modules/product/models/Brand.php b/common/modules/product/models/Brand.php
index f519631..4ccfba4 100755
--- a/common/modules/product/models/Brand.php
+++ b/common/modules/product/models/Brand.php
@@ -60,6 +60,7 @@ class Brand extends \yii\db\ActiveRecord
return [
[['name'], 'string'],
[['brand_name_id'], 'integer'],
+ [['in_menu'], 'boolean'],
[['meta_desc', 'seo_text'], 'string'],
[['alias', 'name'], 'string', 'max' => 250],
[['meta_title', 'image'], 'string', 'max' => 255],
@@ -85,6 +86,7 @@ class Brand extends \yii\db\ActiveRecord
'meta_desc' => Yii::t('product', 'Meta Desc'),
'meta_robots' => Yii::t('product', 'Meta Robots'),
'seo_text' => Yii::t('product', 'Seo Text'),
+ 'in_menu' => Yii::t('product', 'Выводить в меню'),
];
}
diff --git a/frontend/controllers/CatalogController.php b/frontend/controllers/CatalogController.php
index afe354c..d4a8377 100755
--- a/frontend/controllers/CatalogController.php
+++ b/frontend/controllers/CatalogController.php
@@ -164,19 +164,19 @@ class CatalogController extends \yii\web\Controller
]);
}
- public function actionBrands()
- {
- $dataProvider = new ActiveDataProvider([
- 'query' => Brand::find()->orderBy('name'),
- 'pagination' => [
- 'pageSize' => -1,
- ]
- ]);
-
- return $this->render('brands', [
- 'dataProvider' => $dataProvider,
- ]);
- }
+// public function actionBrands()
+// {
+// $dataProvider = new ActiveDataProvider([
+// 'query' => Brand::find()->orderBy('name'),
+// 'pagination' => [
+// 'pageSize' => -1,
+// ]
+// ]);
+//
+// return $this->render('brands', [
+// 'dataProvider' => $dataProvider,
+// ]);
+// }
public function actionBrand($brand)
{
diff --git a/frontend/views/catalog/brand.php b/frontend/views/catalog/brand.php
new file mode 100755
index 0000000..c1bfd61
--- /dev/null
+++ b/frontend/views/catalog/brand.php
@@ -0,0 +1,241 @@
+params['seo']['title'] = !empty($category->meta_title) ? $category->meta_title : '';
+
+$this->params['seo']['fields']['meta-title'] = $category->meta_title;
+$this->params['seo']['h1'] = !empty($category->h1) ? $category->h1 : $category->name;
+$this->params['seo']['seo_text'] = $category->seo_text;
+$this->params['seo']['description'] = $category->meta_desc;
+$this->params['seo']['meta'] = $category->meta_robots;
+$this->params['seo']['category_name'] = $category->name;
+
+$this->params['breadcrumbs'][] = $category->name;
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+ |
+ |
+
+ |
+
+
+
+ |
+ |
+ |
+
+
+ |
+ |
+ |
+
+
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
= Seo::widget([ 'row'=>'h1'])?>
+
+
+
+
+ Сортировка:
+ = \yii\widgets\LinkSorter::widget([
+ 'sort' => $productProvider->sort,
+ 'attributes' => [
+ 'price',
+ ]
+ ]);
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+ = ListView::widget([
+ 'dataProvider' => $productProvider,
+ 'itemView' => function ($model, $key, $index, $widget) use($category) {
+ return $this->render('_product_item',[
+ 'model' => $model,
+ 'category' => $category
+ ]);
+ },
+ 'layout' => "{items}
{pager}",
+ ])
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/views/catalog/products.php b/frontend/views/catalog/products.php
index ba6e08a..5ebcd39 100755
--- a/frontend/views/catalog/products.php
+++ b/frontend/views/catalog/products.php
@@ -36,324 +36,104 @@ use yii\helpers\Url;
-->