xhOrderGoods.php 1.7 KB

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