Spec.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace addons\TinyShop\common\models\product;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%addon_tiny_shop_product_spec}}".
  6. *
  7. * @property int $id
  8. * @property int|null $merchant_id 商户id
  9. * @property int $product_id 商品编码
  10. * @property int $common_spec_id 系统规格id
  11. * @property string $title 规格名称
  12. * @property int $sort 排序
  13. * @property int|null $type 展示方式 1 文字 2 颜色 3 图片
  14. * @property int $status 状态(-1:已删除,0:禁用,1:正常)
  15. * @property int|null $created_at 创建时间
  16. * @property int|null $updated_at 修改时间
  17. */
  18. class Spec extends \common\models\base\BaseModel
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public static function tableName()
  24. {
  25. return '{{%addon_tiny_shop_product_spec}}';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['merchant_id', 'product_id', 'common_spec_id', 'sort', 'type', 'status', 'created_at', 'updated_at'], 'integer'],
  34. [['product_id'], 'required'],
  35. [['title'], 'string', 'max' => 125],
  36. ];
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function attributeLabels()
  42. {
  43. return [
  44. 'id' => 'ID',
  45. 'merchant_id' => '商户id',
  46. 'product_id' => '商品编码',
  47. 'common_spec_id' => '系统规格id',
  48. 'title' => '规格名称',
  49. 'sort' => '排序',
  50. 'type' => '展示方式 1 文字 2 颜色 3 图片',
  51. 'status' => '状态(-1:已删除,0:禁用,1:正常)',
  52. 'created_at' => '创建时间',
  53. 'updated_at' => '修改时间',
  54. ];
  55. }
  56. /**
  57. * @return \yii\db\ActiveQuery
  58. */
  59. public function getValue()
  60. {
  61. return $this->hasMany(SpecValue::class, ['product_id' => 'product_id']);
  62. }
  63. /**
  64. * @return \yii\db\ActiveQuery
  65. */
  66. public function getValueBySpec()
  67. {
  68. return $this->hasMany(SpecValue::class, ['common_spec_id' => 'common_spec_id']);
  69. }
  70. }
粤ICP备19079148号