xhCart.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace common\models;
  3. /**
  4. * This is the model class for table "xhCart".
  5. *
  6. * @property integer $id
  7. * @property integer $userId
  8. * @property integer $merchantId
  9. * @property integer $goodsId
  10. * @property integer $num
  11. * @property string $createTime
  12. * @property string $updateTime
  13. */
  14. class xhCart extends xhBaseModel
  15. {
  16. /**
  17. * @inheritdoc
  18. */
  19. public static function tableName()
  20. {
  21. return 'xhCart';
  22. }
  23. /**
  24. * @inheritdoc
  25. */
  26. public function rules()
  27. {
  28. return [
  29. [['userId', 'merchantId', 'goodsId', 'num', 'goodsPriceId'], 'integer'],
  30. [['createTime'], 'required'],
  31. [['createTime', 'updateTime'], 'safe'],
  32. ];
  33. }
  34. /**
  35. * @inheritdoc
  36. */
  37. public function attributeLabels()
  38. {
  39. return [
  40. 'id' => 'ID',
  41. 'userId' => 'User ID',
  42. 'merchantId' => 'Merchant ID',
  43. 'goodsId' => 'Goods ID',
  44. 'goodsPriceId' => 'Goods Price Id',
  45. 'num' => 'Num',
  46. 'createTime' => 'Create Time',
  47. 'updateTime' => 'Update Time',
  48. ];
  49. }
  50. public function getXhGoods()
  51. {
  52. // 关系和商品通过 Goods.id -> goodsId 关联建立一对一关系
  53. return $this->hasOne(xhGoods::className(), ['id' => 'goodsId']);
  54. }
  55. }