diff --git a/backend/controllers/BrandController.php b/backend/controllers/BrandController.php index a15be2f..a6243c0 100755 --- a/backend/controllers/BrandController.php +++ b/backend/controllers/BrandController.php @@ -97,11 +97,7 @@ class BrandController extends Controller public function actionUpdate($id) { $model = $this->findModel($id); - - var_dump($_POST); - print "\n+++++++++++++++++++++++++++++++++++++\n"; - var_dump($_FILES); - exit; + $model->setScenario('update'); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->brand_id]); diff --git a/backend/views/brand/_form.php b/backend/views/brand/_form.php index 2e02b74..e2f90b5 100755 --- a/backend/views/brand/_form.php +++ b/backend/views/brand/_form.php @@ -18,7 +18,9 @@ use yii\widgets\ActiveForm; = $form->field($model, 'alias')->textInput(['maxlength' => true]) ?> - = \common\components\artboximage\ArtboxImageHelper::fileinputWidget($model, 'imageUrl');?> + + + = $form->field($model, 'image')->fileInput(['accept' => 'image/*']) ?> = $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?> diff --git a/common/modules/product/models/Brand.php b/common/modules/product/models/Brand.php index b9ab809..22db37a 100755 --- a/common/modules/product/models/Brand.php +++ b/common/modules/product/models/Brand.php @@ -4,6 +4,8 @@ namespace common\modules\product\models; use common\behaviors\Slug; use common\modules\rubrication\behaviors\ArtboxSynonymBehavior; +use mongosoft\file\UploadBehavior; +use mongosoft\file\UploadImageBehavior; use Yii; /** @@ -25,7 +27,6 @@ use Yii; */ class Brand extends \yii\db\ActiveRecord { - public $imageUpload; public function behaviors() { @@ -43,6 +44,18 @@ class Brand extends \yii\db\ActiveRecord 'slugKeyName' => 'alias', 'translit' => true ], + 'uploader' => [ + 'class' => UploadImageBehavior::className(), + 'attribute' => 'image', + 'scenarios' => ['insert', 'update'], +// 'placeholder' => '@app/modules/user/assets/images/userpic.jpg', + 'path' => '@storage/{alias}', + 'url' => '/storage/{alias}', +// 'thumbs' => [ +// 'thumb' => ['width' => 400, 'quality' => 90], +// 'preview' => ['width' => 200, 'height' => 200], +// ], + ], ], ]; } @@ -67,8 +80,7 @@ class Brand extends \yii\db\ActiveRecord [['alias', 'name'], 'string', 'max' => 250], [['image', 'meta_title'], 'string', 'max' => 255], [['meta_robots'], 'string', 'max' => 50], - [['imageUpload'], 'safe'], - [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], + ['image', 'file', 'extensions' => 'jpg, gif, png', 'on' => ['insert', 'update']], // [['brand_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandName::className(), 'targetAttribute' => ['brand_name_id' => 'brand_name_id']], ]; } diff --git a/common/modules/product/widgets/lastProducts.php b/common/modules/product/widgets/lastProducts.php index 225b655..ab00838 100644 --- a/common/modules/product/widgets/lastProducts.php +++ b/common/modules/product/widgets/lastProducts.php @@ -15,6 +15,7 @@ class lastProducts extends Widget { public function run() { return $this->render('products_block', [ 'title' => \Yii::t('product', 'Вы недавно просматривали'), + 'class' => 'last-products', 'products' => ProductHelper::getLastProducts(true), ]); } diff --git a/common/modules/product/widgets/specialProducts.php b/common/modules/product/widgets/specialProducts.php index 3f0d5c0..a083696 100644 --- a/common/modules/product/widgets/specialProducts.php +++ b/common/modules/product/widgets/specialProducts.php @@ -40,6 +40,7 @@ class specialProducts extends Widget { return $this->render('products_block', [ 'title' => $this->title, + 'class' => $this->type, 'products' => $products, ]); } diff --git a/common/modules/product/widgets/views/products_block.php b/common/modules/product/widgets/views/products_block.php index 4f0d380..962ee15 100644 --- a/common/modules/product/widgets/views/products_block.php +++ b/common/modules/product/widgets/views/products_block.php @@ -1,4 +1,4 @@ -