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']); + } }