This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
yoshop/source/application/common/model/OrderGoods.php

73 lines
1.4 KiB
PHP
Raw Normal View History

2020-04-25 22:20:29 +08:00
<?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']);
}
}