FoodOrderDetail.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\plugins\food\models;
  8. use Yii;
  9. /**
  10. * This is the model class for table "{{%food_order_detail}}".
  11. *
  12. * @property integer $id
  13. * @property integer $order_id
  14. * @property integer $goods_id
  15. * @property integer $num
  16. * @property string $total_price
  17. * @property integer $created_at
  18. * @property integer $is_delete
  19. * @property string $attr
  20. * @property string $pic
  21. * @property integer $is_level
  22. * @property string $goods_name
  23. * @property string $goods_info
  24. * @property integer $times
  25. */
  26. class FoodOrderDetail extends \yii\db\ActiveRecord
  27. {
  28. /**
  29. * @inheritdoc
  30. */
  31. public static function tableName()
  32. {
  33. return '{{%food_order_detail}}';
  34. }
  35. /**
  36. * @inheritdoc
  37. */
  38. public function rules()
  39. {
  40. return [
  41. [['order_id', 'goods_id', 'attr', 'pic'], 'required'],
  42. [['order_id', 'goods_id', 'num', 'created_at', 'is_delete', 'is_level', 'times'], 'integer'],
  43. [['total_price'], 'number'],
  44. [['attr'], 'string'],
  45. [['pic', 'goods_name'], 'string', 'max' => 255],
  46. ];
  47. }
  48. /**
  49. * @inheritdoc
  50. */
  51. public function attributeLabels()
  52. {
  53. return [
  54. 'id' => 'ID',
  55. 'order_id' => 'Order ID',
  56. 'goods_id' => 'Goods ID',
  57. 'num' => '商品数量',
  58. 'total_price' => '此商品的总价',
  59. 'created_at' => 'Addtime',
  60. 'is_delete' => 'Is Delete',
  61. 'attr' => '商品规格',
  62. 'pic' => '商品规格图片',
  63. 'is_level' => '会员折扣',
  64. 'goods_name' => '商品名称',
  65. ];
  66. }
  67. public function getGoods()
  68. {
  69. return $this->hasOne(FoodGoods::className(), ['id'=>'goods_id']);
  70. }
  71. public function getOrder() {
  72. return $this->hasOne(FoodOrder::className(), ['id' => 'order_id']);
  73. }
  74. }