diff --git a/backend/views/brand/_form.php b/backend/views/brand/_form.php index 7c4530d..6f59b82 100755 --- a/backend/views/brand/_form.php +++ b/backend/views/brand/_form.php @@ -1,57 +1,106 @@
+ + false, + 'options' => [ 'enctype' => 'multipart/form-data' ], + ] + ); ?> + + field($model, 'name') + ->textInput() ?> + + field($model, 'alias') + ->textInput([ 'maxlength' => true ]) ?> + + field($model, 'image') + ->widget( + \kartik\file\FileInput::classname(), + [ + 'language' => 'ru', + 'options' => [ + 'accept' => 'image/*', + 'multiple' => false, + ], + 'pluginOptions' => [ + 'allowedFileExtensions' => [ + 'jpg', + 'gif', + 'png', + ], + 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage( + $model->imageUrl, + 'list' + ) : '', + 'overwriteInitial' => true, + 'showRemove' => false, + 'showUpload' => false, + 'previewFileType' => 'image', + ], + ] + ); ?> + + field($model, 'description') + ->widget( + CKEditor::className(), + [ + 'editorOptions' => ElFinder::ckeditorOptions( + 'elfinder', + [ + 'preset' => 'full', + //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать + 'inline' => false, + //по умолчанию false]), + 'filebrowserUploadUrl' => Yii::$app->getUrlManager() + ->createUrl('file/uploader/images-upload'), + ] + ), + ] + ) ?> + + field($model, 'meta_title') + ->textInput([ 'maxlength' => true ]) ?> + + field($model, 'meta_desc') + ->textarea([ 'rows' => 6 ]) ?> + + field($model, 'meta_robots') + ->textInput([ 'maxlength' => true ]) ?> + + field($model, 'seo_text') + ->textarea([ 'rows' => 6 ]) ?> + + field($model, 'in_menu') + ->checkbox() ?> - false, - 'options' => ['enctype' => 'multipart/form-data'] - ]); ?> - - field($model, 'name')->textInput() ?> - - field($model, 'alias')->textInput(['maxlength' => true]) ?> - - field($model, 'image')->widget(\kartik\file\FileInput::classname(), [ - 'language' => 'ru', - 'options' => [ - 'accept' => 'image/*', - 'multiple' => false, - ], - 'pluginOptions' => [ - 'allowedFileExtensions' => ['jpg', 'gif', 'png'], - 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '', - 'overwriteInitial' => true, - 'showRemove' => false, - 'showUpload' => false, - 'previewFileType' => 'image', - ], - ]); ?> - - field($model, 'meta_title')->textInput(['maxlength' => true]) ?> - - field($model, 'meta_desc')->textarea(['rows' => 6]) ?> - - field($model, 'meta_robots')->textInput(['maxlength' => true]) ?> - - field($model, 'seo_text')->textarea(['rows' => 6]) ?> - - field($model, 'in_menu')->checkbox()?> - -
- isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> - isNewRecord) :?> - 'create_and_new', 'class' => 'btn btn-primary']) ?> - -
- +
+ isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] + ) ?> + isNewRecord) : ?> + 'create_and_new', + 'class' => 'btn btn-primary', + ] + ) ?> + +
+
diff --git a/common/modules/product/models/Brand.php b/common/modules/product/models/Brand.php index efb9e49..e9704f4 100755 --- a/common/modules/product/models/Brand.php +++ b/common/modules/product/models/Brand.php @@ -1,122 +1,163 @@ SaveImgBehavior::className(), + 'fields' => [ + [ + 'name' => 'image', + 'directory' => 'brands', + ], + ], + ], + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', + 'out_attribute' => 'alias', + 'translit' => true, + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'name', + 'description', + ], + 'string', + ], + [ + [ 'brand_name_id' ], + 'integer', + ], + [ + [ 'in_menu' ], + 'boolean', + ], + [ + [ + 'meta_desc', + 'seo_text', + ], + 'string', + ], + [ + [ + 'alias', + 'name', + ], + 'string', + 'max' => 250, + ], + [ + [ + 'meta_title', + 'image', + ], + 'string', + 'max' => 255, + ], + [ + [ 'meta_robots' ], + 'string', + 'max' => 50, + ], + [ + [ 'imageUpload' ], + 'safe', + ], + [ + [ 'imageUpload' ], + 'file', + 'extensions' => 'jpg, gif, png', + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'name' => Yii::t('product', 'Name of the brand'), + 'brand_id' => Yii::t('product', 'Brand ID'), + 'brand_name_id' => Yii::t('product', 'Brand Name ID'), + 'alias' => Yii::t('product', 'Alias'), + 'image' => Yii::t('product', 'Image'), + 'imageUrl' => Yii::t('product', 'Image'), + 'meta_title' => Yii::t('product', 'Meta Title'), + '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', 'Выводить в меню'), + 'description' => Yii::t('product', 'Описание'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getProducts() + { + return $this->hasMany(Product::className(), [ 'brand_id' => 'brand_id' ]); + } + + public function getImageFile() + { + return empty($this->image) ? NULL : '/storage/brands/' . $this->image; + } + + public function getImageUrl() + { + return empty($this->image) ? NULL : '/storage/brands/' . $this->image; + } + } - - - /** - * @inheritdoc - */ - - public function behaviors() - { - return [ - [ - 'class' => SaveImgBehavior::className(), - 'fields' => [ - ['name'=>'image','directory' => 'brands' ] - ] - ], - 'slug' => [ - 'class' => 'common\behaviors\Slug', - 'in_attribute' => 'name', - 'out_attribute' => 'alias', - 'translit' => true - ], - ]; - } - - /** - * @inheritdoc - */ - public function rules() - { - 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], - [['meta_robots'], 'string', 'max' => 50], - [['imageUpload'], 'safe'], - [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'name' => Yii::t('product', 'Name of the brand'), - 'brand_id' => Yii::t('product', 'Brand ID'), - 'brand_name_id' => Yii::t('product', 'Brand Name ID'), - 'alias' => Yii::t('product', 'Alias'), - 'image' => Yii::t('product', 'Image'), - 'imageUrl' => Yii::t('product', 'Image'), - 'meta_title' => Yii::t('product', 'Meta Title'), - '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', 'Выводить в меню'), - ]; - } - - - - /** - * @return \yii\db\ActiveQuery - */ - public function getProducts() - { - return $this->hasMany(Product::className(), ['brand_id' => 'brand_id']); - } - - public function getImageFile() { - return empty($this->image) ? null : '/storage/brands/'. $this->image; - } - - public function getImageUrl() { - return empty($this->image) ? null : '/storage/brands/'. $this->image; - } - -} diff --git a/console/migrations/m170202_140836_add_description_column_to_brand_table.php b/console/migrations/m170202_140836_add_description_column_to_brand_table.php new file mode 100644 index 0000000..803031b --- /dev/null +++ b/console/migrations/m170202_140836_add_description_column_to_brand_table.php @@ -0,0 +1,25 @@ +addColumn('brand', 'description', $this->text()); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropColumn('brand', 'description'); + } +} diff --git a/frontend/views/catalog/brand.php b/frontend/views/catalog/brand.php index 0d18ec5..470bb5a 100755 --- a/frontend/views/catalog/brand.php +++ b/frontend/views/catalog/brand.php @@ -46,7 +46,9 @@ $this->params['breadcrumbs'][] = $brand->name;

'h1']) ?>

- Seo::SEO_TEXT])) ? Seo::widget(['row' => Seo::SEO_TEXT]) : $brand->seo_text?> + description)) echo $brand->description; + ?>
-- libgit2 0.21.4