Commit 63fd649571ffa2d957d9dfa463e8f1f1f1d60baa
1 parent
fd40a9e1
-Cabinet started
Showing
3 changed files
with
45 additions
and
3 deletions
Show diff stats
migrations/m170511_102711_add_color_column_to_label_table.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | + use yii\db\Migration; | ||
4 | + | ||
5 | + /** | ||
6 | + * Handles adding color to table `label`. | ||
7 | + */ | ||
8 | + class m170511_102711_add_color_column_to_label_table extends Migration | ||
9 | + { | ||
10 | + /** | ||
11 | + * @inheritdoc | ||
12 | + */ | ||
13 | + public function up() | ||
14 | + { | ||
15 | + $this->addColumn('label', 'color', $this->string()); | ||
16 | + } | ||
17 | + | ||
18 | + /** | ||
19 | + * @inheritdoc | ||
20 | + */ | ||
21 | + public function down() | ||
22 | + { | ||
23 | + $this->dropColumn('label', 'color'); | ||
24 | + } | ||
25 | + } |
models/Label.php
@@ -16,10 +16,11 @@ | @@ -16,10 +16,11 @@ | ||
16 | * @property integer $sort | 16 | * @property integer $sort |
17 | * @property string $value | 17 | * @property string $value |
18 | * @property boolean $status | 18 | * @property boolean $status |
19 | + * @property string $color | ||
19 | * @property LabelLang[] $labelLangs | 20 | * @property LabelLang[] $labelLangs |
20 | * @property Language[] $languages | 21 | * @property Language[] $languages |
21 | * @property Order[] $orders | 22 | * @property Order[] $orders |
22 | - * * From language behavior * | 23 | + * * From language behavior * |
23 | * @property LabelLang $lang | 24 | * @property LabelLang $lang |
24 | * @property LabelLang[] $langs | 25 | * @property LabelLang[] $langs |
25 | * @property LabelLang $objectLang | 26 | * @property LabelLang $objectLang |
@@ -40,7 +41,7 @@ | @@ -40,7 +41,7 @@ | ||
40 | * @method bool getTransactionStatus() | 41 | * @method bool getTransactionStatus() |
41 | * @method bool loadWithLangs( Request $request ) | 42 | * @method bool loadWithLangs( Request $request ) |
42 | * @method bool saveWithLangs() | 43 | * @method bool saveWithLangs() |
43 | - * * End language behavior * | 44 | + * * End language behavior * |
44 | * @see LanguageBehavior | 45 | * @see LanguageBehavior |
45 | */ | 46 | */ |
46 | class Label extends ActiveRecord | 47 | class Label extends ActiveRecord |
@@ -76,6 +77,10 @@ | @@ -76,6 +77,10 @@ | ||
76 | 'integer', | 77 | 'integer', |
77 | ], | 78 | ], |
78 | [ | 79 | [ |
80 | + [ 'color' ], | ||
81 | + 'string', | ||
82 | + ], | ||
83 | + [ | ||
79 | [ 'value' ], | 84 | [ 'value' ], |
80 | 'number', | 85 | 'number', |
81 | ], | 86 | ], |
@@ -96,6 +101,7 @@ | @@ -96,6 +101,7 @@ | ||
96 | 'sort' => Yii::t('order', 'Sort'), | 101 | 'sort' => Yii::t('order', 'Sort'), |
97 | 'value' => Yii::t('order', 'Value'), | 102 | 'value' => Yii::t('order', 'Value'), |
98 | 'status' => Yii::t('order', 'Status'), | 103 | 'status' => Yii::t('order', 'Status'), |
104 | + 'color' => Yii::t('order', 'Color'), | ||
99 | ]; | 105 | ]; |
100 | } | 106 | } |
101 | 107 | ||
@@ -113,7 +119,7 @@ | @@ -113,7 +119,7 @@ | ||
113 | public function getLanguages() | 119 | public function getLanguages() |
114 | { | 120 | { |
115 | return $this->hasMany(Language::className(), [ 'id' => 'language_id' ]) | 121 | return $this->hasMany(Language::className(), [ 'id' => 'language_id' ]) |
116 | - ->viaTable('label_lang', [ 'label_id' => 'id' ]); | 122 | + ->viaTable('label_lang', [ 'label_id' => 'id' ]); |
117 | } | 123 | } |
118 | 124 | ||
119 | /** | 125 | /** |
views/label/_form.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use artbox\core\widgets\LanguageForm; | 3 | use artbox\core\widgets\LanguageForm; |
4 | + use kartik\color\ColorInput; | ||
4 | use yii\helpers\Html; | 5 | use yii\helpers\Html; |
5 | use yii\widgets\ActiveForm; | 6 | use yii\widgets\ActiveForm; |
6 | 7 | ||
@@ -36,6 +37,16 @@ | @@ -36,6 +37,16 @@ | ||
36 | 'class' => 'flat', | 37 | 'class' => 'flat', |
37 | ] | 38 | ] |
38 | ) ?> | 39 | ) ?> |
40 | + | ||
41 | + <?php | ||
42 | + echo $form->field($model, 'color') | ||
43 | + ->widget( | ||
44 | + ColorInput::classname(), | ||
45 | + [ | ||
46 | + 'options' => [ 'placeholder' => \Yii::t('app', 'Select color ...') ], | ||
47 | + ] | ||
48 | + ); | ||
49 | + ?> | ||
39 | 50 | ||
40 | <div class="form-group"> | 51 | <div class="form-group"> |
41 | <?= Html::submitButton( | 52 | <?= Html::submitButton( |