GoodsCat.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use Yii;
  9. use yii\behaviors\TimestampBehavior;
  10. /**
  11. * This is the model class for table "{{%goods_cat}}".
  12. *
  13. * @property integer $id
  14. * @property integer $goods_id
  15. * @property integer $store_id
  16. * @property integer $cat_id
  17. * @property integer $is_delete
  18. * @property integer $created_at
  19. * @property integer $updated_at
  20. */
  21. class GoodsCat extends \yii\db\ActiveRecord
  22. {
  23. /**
  24. * @inheritdoc
  25. */
  26. public static function tableName()
  27. {
  28. return '{{%goods_cat}}';
  29. }
  30. public function behaviors()
  31. {
  32. return [
  33. [
  34. // 自动更新创建和更新时间
  35. 'class' => TimestampBehavior::class,
  36. 'value' => time()
  37. ]
  38. ];
  39. }
  40. /**
  41. * @inheritdoc
  42. */
  43. public function rules()
  44. {
  45. return [
  46. [['goods_id', 'store_id', 'cat_id', 'is_delete'], 'integer'],
  47. [['is_delete'], 'default', 'value' => 0]
  48. ];
  49. }
  50. /**
  51. * @inheritdoc
  52. */
  53. public function attributeLabels()
  54. {
  55. return [
  56. 'id' => 'ID',
  57. 'goods_id' => 'Goods ID',
  58. 'store_id' => 'Store ID',
  59. 'cat_id' => '分类id 多个分类用英文逗号隔开',
  60. 'is_delete' => 'Is Delete',
  61. ];
  62. }
  63. // 关联商品表
  64. public function getGoods()
  65. {
  66. return $this->hasOne(Goods::className(), ['id'=>'goods_id']);
  67. }
  68. public function getCat()
  69. {
  70. return $this->hasOne(Cat::className(), ['id' => 'cat_id']);
  71. }
  72. }