You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

61 lines
1.1 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: zhengmingwei
  5. * Date: 2020/1/6
  6. * Time: 11:25 下午
  7. */
  8. namespace addons\unishop\model;
  9. use addons\unishop\extend\Hashids;
  10. use think\Model;
  11. /**
  12. * 订单商品表
  13. * Class OrderExtend
  14. * @package addons\unishop\model
  15. */
  16. class OrderProduct extends Model
  17. {
  18. // 表名
  19. protected $name = 'unishop_order_product';
  20. // 开启自动写入时间戳字段
  21. protected $autoWriteTimestamp = 'int';
  22. // 定义时间戳字段名
  23. protected $createTime = 'createtime';
  24. protected $updateTime = 'updatetime';
  25. // 隐藏属性
  26. protected $hidden = [
  27. 'user_id',
  28. 'order_id',
  29. 'product_id'
  30. ];
  31. protected $append = [
  32. 'order_product_id'
  33. ];
  34. public function getIdAttr($value, $data)
  35. {
  36. return Hashids::encodeHex($data['product_id']);
  37. }
  38. public function getOrderProductIdAttr($value, $data)
  39. {
  40. return $data['id'];
  41. }
  42. /**
  43. * 关联商品信息
  44. */
  45. public function product()
  46. {
  47. return $this->hasOne('product', 'id', 'product_id');
  48. }
  49. }