123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\common\model;
- /**
- * 订单商品模型
- * Class OrderGoods
- * @package app\common\model
- */
- class OrderGoods extends BaseModel
- {
- protected $name = 'order_goods';
- protected $updateTime = false;
- /**
- * 订单商品列表
- * @return \think\model\relation\BelongsTo
- */
- public function image()
- {
- $model = "app\\common\\model\\UploadFile";
- return $this->belongsTo($model, 'image_id', 'file_id');
- }
- /**
- * 关联商品表
- * @return \think\model\relation\BelongsTo
- */
- public function goods()
- {
- return $this->belongsTo('Goods');
- }
- /**
- * 关联商品sku表
- * @return \think\model\relation\BelongsTo
- */
- // public function sku()
- // {
- // return $this->belongsTo('GoodsSku', 'spec_sku_id', 'spec_sku_id');
- // }
- /**
- * 关联订单主表
- * @return \think\model\relation\BelongsTo
- */
- public function orderM()
- {
- return $this->belongsTo('Order');
- }
- /**
- * 售后单记录表
- * @return \think\model\relation\HasOne
- */
- public function refund()
- {
- return $this->hasOne('OrderRefund');
- }
- /**
- * 订单商品详情
- * @param $where
- * @return OrderGoods|null
- * @throws \think\exception\DbException
- */
- public static function detail($where)
- {
- return static::get($where, ['image', 'refund']);
- }
- }
|