|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- /**
- * Created by PhpStorm.
- * User: zhengmingwei
- * Date: 2020/1/6
- * Time: 11:25 下午
- */
-
-
- namespace addons\unishop\model;
-
- use addons\unishop\extend\Hashids;
- use think\Model;
-
- /**
- * 订单商品表
- * Class OrderExtend
- * @package addons\unishop\model
- */
- class OrderProduct extends Model
- {
- // 表名
- protected $name = 'unishop_order_product';
-
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
-
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
-
- // 隐藏属性
- protected $hidden = [
- 'user_id',
- 'order_id',
- 'product_id'
- ];
-
- protected $append = [
- 'order_product_id'
- ];
-
- public function getIdAttr($value, $data)
- {
- return Hashids::encodeHex($data['product_id']);
- }
-
- public function getOrderProductIdAttr($value, $data)
- {
- return $data['id'];
- }
-
- /**
- * 关联商品信息
- */
- public function product()
- {
- return $this->hasOne('product', 'id', 'product_id');
- }
- }
|