From 424a84cd2ac7cb573980bf4029f47d2acabcab27 Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Sat, 30 Nov 2019 08:56:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E6=A0=BC=E8=A1=A8=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E5=95=86=E5=93=81=E5=88=86=E7=B1=BBid?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...umn_cat_id_in_table_antgoods_attribute.php | 20 +++++++++++++++++++ .../goods/src/models/ars/Attribute.php | 10 +++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 vendor/antgoods/goods/src/migrations/m191130_004933_add_column_cat_id_in_table_antgoods_attribute.php diff --git a/vendor/antgoods/goods/src/migrations/m191130_004933_add_column_cat_id_in_table_antgoods_attribute.php b/vendor/antgoods/goods/src/migrations/m191130_004933_add_column_cat_id_in_table_antgoods_attribute.php new file mode 100644 index 0000000..f7992f5 --- /dev/null +++ b/vendor/antgoods/goods/src/migrations/m191130_004933_add_column_cat_id_in_table_antgoods_attribute.php @@ -0,0 +1,20 @@ +addColumn('antgoods_attribute', 'cat_id', $this->integer(11)->notNull()->defaultValue(0)->comment('后台商品分类id')); + } + + public function down() + { + $this->dropColumn('antgoods_attribute', 'cat_id'); + return true; + } +} diff --git a/vendor/antgoods/goods/src/models/ars/Attribute.php b/vendor/antgoods/goods/src/models/ars/Attribute.php index 84178f2..711b266 100644 --- a/vendor/antgoods/goods/src/models/ars/Attribute.php +++ b/vendor/antgoods/goods/src/models/ars/Attribute.php @@ -4,6 +4,7 @@ namespace antgoods\goods\models\ars; use Yii; use yii\behaviors\TimestampBehavior; +use antgoods\goods\models\ars\Category; /** * This is the model class for table "antgoods_attribute". @@ -16,6 +17,7 @@ use yii\behaviors\TimestampBehavior; * @property int $is_delete 是否删除,1为已删除 * @property int $created_at 创建时间 * @property int $updated_at 更新时间 + * @property int $cat_id 后台商品分类id */ class Attribute extends \yii\db\ActiveRecord { @@ -40,7 +42,7 @@ class Attribute extends \yii\db\ActiveRecord return [ [['name', 'value'], 'required'], [['value'], 'string'], - [['type', 'sort_order', 'is_delete'], 'integer'], + [['type', 'sort_order', 'is_delete', 'cat_id'], 'integer'], [['name'], 'string', 'max' => 50], ]; } @@ -59,6 +61,7 @@ class Attribute extends \yii\db\ActiveRecord 'is_delete' => '是否删除,1为已删除', 'created_at' => '创建时间', 'updated_at' => '更新时间', + 'cat_id' => '后台商品分类id', ]; } @@ -100,4 +103,9 @@ class Attribute extends \yii\db\ActiveRecord } return parent::beforeSave($insert); // TODO: Change the autogenerated stub } + + public function getCategory() + { + return $this->hasOne(Category::className(), ['id' => 'cat_id']); + } }