Browse Source

规格表增加后台商品分类id字段

wechat_public_accounts
linyaostalker 5 years ago
parent
commit
424a84cd2a
  1. 20
      vendor/antgoods/goods/src/migrations/m191130_004933_add_column_cat_id_in_table_antgoods_attribute.php
  2. 10
      vendor/antgoods/goods/src/models/ars/Attribute.php

20
vendor/antgoods/goods/src/migrations/m191130_004933_add_column_cat_id_in_table_antgoods_attribute.php

@ -0,0 +1,20 @@
<?php
use yii\db\Migration;
/**
* Class m191130_004933_add_column_cat_id_in_table_antgoods_attribute
*/
class m191130_004933_add_column_cat_id_in_table_antgoods_attribute extends Migration
{
public function up()
{
$this->addColumn('antgoods_attribute', 'cat_id', $this->integer(11)->notNull()->defaultValue(0)->comment('后台商品分类id'));
}
public function down()
{
$this->dropColumn('antgoods_attribute', 'cat_id');
return true;
}
}

10
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']);
}
}
Loading…
Cancel
Save