Commit 4fd34610df4eccdae61e6e30dbdfcb6268548452
1 parent
88fd5f89
add tiles
Showing
5 changed files
with
278 additions
and
107 deletions
 
Show diff stats
backend/views/objectkb/_form.php
| @@ -57,7 +57,12 @@ | @@ -57,7 +57,12 @@ | ||
| 57 | 57 | ||
| 58 | <?= $form->field($model, 'sort') | 58 | <?= $form->field($model, 'sort') | 
| 59 | ->textInput() ?> | 59 | ->textInput() ?> | 
| 60 | - | 60 | + <?= $form->field($model, 'invertor_power') | 
| 61 | + ->textInput() ?> | ||
| 62 | + <?= $form->field($model, 'module_power') | ||
| 63 | + ->textInput() ?> | ||
| 64 | + <?= $form->field($model, 'price') | ||
| 65 | + ->textInput() ?> | ||
| 61 | <?= $form->field($model, 'image_mini_id') | 66 | <?= $form->field($model, 'image_mini_id') | 
| 62 | ->widget( | 67 | ->widget( | 
| 63 | ImageManagerInputWidget::className(), | 68 | ImageManagerInputWidget::className(), | 
common/models/Objectkb.php
| 1 | <?php | 1 | <?php | 
| 2 | + | ||
| 3 | +namespace common\models; | ||
| 4 | + | ||
| 5 | +use yii\db\ActiveRecord; | ||
| 6 | +use artbox\core\behaviors\LanguageBehavior; | ||
| 7 | +use artbox\core\models\Image; | ||
| 8 | +use Yii; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * User: timur | ||
| 12 | + * Date: 25.01.18 | ||
| 13 | + * Time: 12:46 | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * Class Objectkb | ||
| 18 | + * | ||
| 19 | + * @package common\models | ||
| 20 | + * @property \common\models\ObjectkbLang $lang | ||
| 21 | + */ | ||
| 22 | +class Objectkb extends ActiveRecord | ||
| 23 | +{ | ||
| 24 | + const TYPE_DEFAULT = 0; | ||
| 25 | + const TYPE_COMPANY = 1; | ||
| 26 | + const TYPE_PRIVATE = 2; | ||
| 2 | 27 | ||
| 3 | - namespace common\models; | ||
| 4 | - | ||
| 5 | - use yii\db\ActiveRecord; | ||
| 6 | - use artbox\core\behaviors\LanguageBehavior; | ||
| 7 | - use artbox\core\models\Image; | ||
| 8 | - use Yii; | 28 | + /** | 
| 29 | + * @inheritdoc | ||
| 30 | + */ | ||
| 31 | + public static function tableName() | ||
| 32 | + { | ||
| 33 | + return 'object'; | ||
| 34 | + } | ||
| 9 | 35 | ||
| 10 | /** | 36 | /** | 
| 11 | - * User: timur | ||
| 12 | - * Date: 25.01.18 | ||
| 13 | - * Time: 12:46 | 37 | + * @inheritdoc | 
| 14 | */ | 38 | */ | 
| 15 | - | 39 | + public function behaviors() | 
| 40 | + { | ||
| 41 | + return [ | ||
| 42 | + 'language' => [ | ||
| 43 | + 'class' => LanguageBehavior::className(), | ||
| 44 | + ], | ||
| 45 | + ]; | ||
| 46 | + } | ||
| 47 | + | ||
| 16 | /** | 48 | /** | 
| 17 | - * Class Objectkb | ||
| 18 | - * | ||
| 19 | - * @package common\models | ||
| 20 | - * @property \common\models\ObjectkbLang $lang | ||
| 21 | - * | 49 | + * @inheritdoc | 
| 22 | */ | 50 | */ | 
| 23 | - class Objectkb extends ActiveRecord | 51 | + public function rules() | 
| 24 | { | 52 | { | 
| 25 | - const TYPE_DEFAULT = 0; | ||
| 26 | - const TYPE_COMPANY = 1; | ||
| 27 | - const TYPE_PRIVATE = 2; | ||
| 28 | - | ||
| 29 | - /** | ||
| 30 | - * @inheritdoc | ||
| 31 | - */ | ||
| 32 | - public static function tableName() | ||
| 33 | - { | ||
| 34 | - return 'object'; | ||
| 35 | - } | ||
| 36 | - | ||
| 37 | - /** | ||
| 38 | - * @inheritdoc | ||
| 39 | - */ | ||
| 40 | - public function behaviors() | ||
| 41 | - { | ||
| 42 | - return [ | ||
| 43 | - 'language' => [ | ||
| 44 | - 'class' => LanguageBehavior::className(), | ||
| 45 | - ], | ||
| 46 | - ]; | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - /** | ||
| 50 | - * @inheritdoc | ||
| 51 | - */ | ||
| 52 | - public function rules() | ||
| 53 | - { | ||
| 54 | - return [ | ||
| 55 | - [ | ||
| 56 | - [ | ||
| 57 | - 'slider_id', | ||
| 58 | - 'image_mini_id', | ||
| 59 | - ], | ||
| 60 | - 'required', | ||
| 61 | - ], | 53 | + return [ | 
| 54 | + [ | ||
| 62 | [ | 55 | [ | 
| 63 | - [ | ||
| 64 | - 'slider_id', | ||
| 65 | - 'sort', | ||
| 66 | - 'type' | ||
| 67 | - ], | ||
| 68 | - 'integer', | 56 | + 'slider_id', | 
| 57 | + 'image_mini_id', | ||
| 69 | ], | 58 | ], | 
| 59 | + 'required', | ||
| 60 | + ], | ||
| 61 | + [ | ||
| 70 | [ | 62 | [ | 
| 71 | - [ 'status' ], | ||
| 72 | - 'boolean', | 63 | + 'slider_id', | 
| 64 | + 'sort', | ||
| 65 | + 'type', | ||
| 73 | ], | 66 | ], | 
| 74 | - [ | ||
| 75 | - [ 'slider_id' ], | ||
| 76 | - 'exist', | ||
| 77 | - 'skipOnError' => true, | ||
| 78 | - 'targetClass' => Slider::className(), | ||
| 79 | - 'targetAttribute' => [ 'slider_id' => 'id' ], | ||
| 80 | - ], | ||
| 81 | - [ | ||
| 82 | - [ 'image_mini_id' ], | ||
| 83 | - 'exist', | ||
| 84 | - 'skipOnError' => true, | ||
| 85 | - 'targetClass' => Image::className(), | ||
| 86 | - 'targetAttribute' => [ 'image_mini_id' => 'id' ], | ||
| 87 | - ], | ||
| 88 | - ]; | ||
| 89 | - } | 67 | + 'integer', | 
| 68 | + ], | ||
| 69 | + [ | ||
| 70 | + ['invertor_power', 'module_power', 'price'], | ||
| 71 | + 'string', | ||
| 72 | + 'max' => 255, | ||
| 73 | + ], | ||
| 74 | + [ | ||
| 75 | + ['status'], | ||
| 76 | + 'boolean', | ||
| 77 | + ], | ||
| 78 | + [ | ||
| 79 | + ['slider_id'], | ||
| 80 | + 'exist', | ||
| 81 | + 'skipOnError' => true, | ||
| 82 | + 'targetClass' => Slider::className(), | ||
| 83 | + 'targetAttribute' => ['slider_id' => 'id'], | ||
| 84 | + ], | ||
| 85 | + [ | ||
| 86 | + ['image_mini_id'], | ||
| 87 | + 'exist', | ||
| 88 | + 'skipOnError' => true, | ||
| 89 | + 'targetClass' => Image::className(), | ||
| 90 | + 'targetAttribute' => ['image_mini_id' => 'id'], | ||
| 91 | + ], | ||
| 92 | + ]; | ||
| 93 | + } | ||
| 90 | 94 | ||
| 91 | - /** | ||
| 92 | - * @inheritdoc | ||
| 93 | - */ | ||
| 94 | - public function attributeLabels() | ||
| 95 | - { | ||
| 96 | - return [ | ||
| 97 | - 'id' => Yii::t('core', 'ID'), | ||
| 98 | - 'slider_id' => Yii::t('core', 'Slider ID'), | ||
| 99 | - 'status' => Yii::t('core', 'Status'), | ||
| 100 | - 'sort' => Yii::t('core', 'Sort'), | ||
| 101 | - 'image_mini_id' => Yii::t('core', 'Image Mini'), | ||
| 102 | - 'type' => 'Тип Объекта для главной' | ||
| 103 | - ]; | ||
| 104 | - } | 95 | + /** | 
| 96 | + * @inheritdoc | ||
| 97 | + */ | ||
| 98 | + public function attributeLabels() | ||
| 99 | + { | ||
| 100 | + return [ | ||
| 101 | + 'id' => Yii::t('core', 'ID'), | ||
| 102 | + 'slider_id' => Yii::t('core', 'Slider ID'), | ||
| 103 | + 'status' => Yii::t('core', 'Status'), | ||
| 104 | + 'sort' => Yii::t('core', 'Sort'), | ||
| 105 | + 'image_mini_id' => Yii::t('core', 'Image Mini'), | ||
| 106 | + 'type' => 'Тип Объекта для главной', | ||
| 107 | + ]; | ||
| 108 | + } | ||
| 105 | 109 | ||
| 106 | - /** | ||
| 107 | - * @return \yii\db\ActiveQuery | ||
| 108 | - */ | ||
| 109 | - public function getImage() | ||
| 110 | - { | ||
| 111 | - return $this->hasOne(Image::className(), [ 'id' => 'image_mini_id' ]); | ||
| 112 | - } | 110 | + /** | 
| 111 | + * @return \yii\db\ActiveQuery | ||
| 112 | + */ | ||
| 113 | + public function getImage() | ||
| 114 | + { | ||
| 115 | + return $this->hasOne(Image::className(), ['id' => 'image_mini_id']); | ||
| 116 | + } | ||
| 113 | 117 | ||
| 114 | - /** | ||
| 115 | - * @return \yii\db\ActiveQuery | ||
| 116 | - */ | ||
| 117 | - public function getSlider() | ||
| 118 | - { | ||
| 119 | - return $this->hasOne(Slider::className(), [ 'id' => 'slider_id' ]); | ||
| 120 | - } | ||
| 121 | - } | ||
| 122 | \ No newline at end of file | 118 | \ No newline at end of file | 
| 119 | + /** | ||
| 120 | + * @return \yii\db\ActiveQuery | ||
| 121 | + */ | ||
| 122 | + public function getSlider() | ||
| 123 | + { | ||
| 124 | + return $this->hasOne(Slider::className(), ['id' => 'slider_id']); | ||
| 125 | + } | ||
| 126 | +} | ||
| 123 | \ No newline at end of file | 127 | \ No newline at end of file | 
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace common\models; | ||
| 4 | + | ||
| 5 | +use artbox\core\behaviors\LanguageBehavior; | ||
| 6 | +use yii\db\ActiveRecord; | ||
| 7 | + | ||
| 8 | +class Tile extends ActiveRecord | ||
| 9 | +{ | ||
| 10 | + /** | ||
| 11 | + * @inheritdoc | ||
| 12 | + */ | ||
| 13 | + public static function tableName() | ||
| 14 | + { | ||
| 15 | + return 'tile'; | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + public function behaviors() | ||
| 19 | + { | ||
| 20 | + return [ | ||
| 21 | + 'language' => [ | ||
| 22 | + 'class' => LanguageBehavior::className(), | ||
| 23 | + ], | ||
| 24 | + ]; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public function rules() | ||
| 28 | + { | ||
| 29 | + return [ | ||
| 30 | + [ | ||
| 31 | + [ | ||
| 32 | + 'image', | ||
| 33 | + ], | ||
| 34 | + 'required', | ||
| 35 | + ], | ||
| 36 | + [ | ||
| 37 | + [ | ||
| 38 | + 'image', | ||
| 39 | + ], | ||
| 40 | + 'string', | ||
| 41 | + ], | ||
| 42 | + [ | ||
| 43 | + [ | ||
| 44 | + 'status', | ||
| 45 | + ], | ||
| 46 | + 'boolean', | ||
| 47 | + ], | ||
| 48 | + [ | ||
| 49 | + [ | ||
| 50 | + 'sort', | ||
| 51 | + ], | ||
| 52 | + 'integer', | ||
| 53 | + ], | ||
| 54 | + ]; | ||
| 55 | + } | ||
| 56 | +} | ||
| 0 | \ No newline at end of file | 57 | \ No newline at end of file | 
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace common\models; | ||
| 4 | + | ||
| 5 | +use artbox\core\models\Image; | ||
| 6 | +use artbox\core\models\Language; | ||
| 7 | +use artbox\core\models\Slide; | ||
| 8 | +use yii\db\ActiveRecord; | ||
| 9 | + | ||
| 10 | +class TileLang extends ActiveRecord | ||
| 11 | +{ | ||
| 12 | + /** | ||
| 13 | + * @inheritdoc | ||
| 14 | + */ | ||
| 15 | + public static function tableName() | ||
| 16 | + { | ||
| 17 | + return 'tile_lang'; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * @inheritdoc | ||
| 22 | + */ | ||
| 23 | + public function rules() | ||
| 24 | + { | ||
| 25 | + return [ | ||
| 26 | + [ | ||
| 27 | + [ | ||
| 28 | + 'tile_id', | ||
| 29 | + 'language_id', | ||
| 30 | + //'image_id', | ||
| 31 | + ], | ||
| 32 | + 'required', | ||
| 33 | + ], | ||
| 34 | + [ | ||
| 35 | + [ | ||
| 36 | + 'tile_id', | ||
| 37 | + 'language_id', | ||
| 38 | + // 'image_id', | ||
| 39 | + ], | ||
| 40 | + 'integer', | ||
| 41 | + ], | ||
| 42 | + [ | ||
| 43 | + [ | ||
| 44 | + 'link', | ||
| 45 | + 'title', | ||
| 46 | + ], | ||
| 47 | + 'string', | ||
| 48 | + 'max' => 255, | ||
| 49 | + ], | ||
| 50 | + [ | ||
| 51 | + [ 'language_id' ], | ||
| 52 | + 'exist', | ||
| 53 | + 'skipOnError' => true, | ||
| 54 | + 'targetClass' => Language::className(), | ||
| 55 | + 'targetAttribute' => [ 'language_id' => 'id' ], | ||
| 56 | + ], | ||
| 57 | + [ | ||
| 58 | + [ 'slide_id' ], | ||
| 59 | + 'exist', | ||
| 60 | + 'skipOnError' => true, | ||
| 61 | + 'targetClass' => Tile::className(), | ||
| 62 | + 'targetAttribute' => [ 'tile_id' => 'id' ], | ||
| 63 | + ], | ||
| 64 | + ]; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + | ||
| 68 | + /** | ||
| 69 | + * @return \yii\db\ActiveQuery | ||
| 70 | + */ | ||
| 71 | + public function getLanguage() | ||
| 72 | + { | ||
| 73 | + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * @return \yii\db\ActiveQuery | ||
| 78 | + */ | ||
| 79 | + public function getTile() | ||
| 80 | + { | ||
| 81 | + return $this->hasOne(Tile::className(), [ 'id' => 'tile_id' ]); | ||
| 82 | + } | ||
| 83 | +} | ||
| 0 | \ No newline at end of file | 84 | \ No newline at end of file | 
console/migrations/m211110_160643_add_price_column_to_object_table.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\db\Migration; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * Handles adding price to table `object`. | ||
| 7 | + */ | ||
| 8 | +class m211110_160643_add_price_column_to_object_table extends Migration | ||
| 9 | +{ | ||
| 10 | + public function up() | ||
| 11 | + { | ||
| 12 | + $this->addColumn('object', 'price', $this->string()); | ||
| 13 | + $this->addColumn('object', 'module_power', $this->string()); | ||
| 14 | + $this->addColumn('object', 'invertor_power', $this->string()); | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + public function down() | ||
| 18 | + { | ||
| 19 | + $this->dropColumn('object', 'price'); | ||
| 20 | + $this->dropColumn('object', 'module_power'); | ||
| 21 | + $this->dropColumn('object', 'invertor_power'); | ||
| 22 | + } | ||
| 23 | +} | 
