UserCollageCode.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\model\activity\collage;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use app\model\order\StoreOrder;
  15. use app\model\activity\table\TableQrcode;
  16. /**
  17. * 拼单Model
  18. * Class UserCollage
  19. * @package app\model\collage
  20. */
  21. class UserCollageCode extends BaseModel
  22. {
  23. use ModelTrait;
  24. /**
  25. * 数据表主键
  26. * @var string
  27. */
  28. protected $pk = 'id';
  29. /**
  30. * 模型名称
  31. * @var string
  32. */
  33. protected $name = 'user_collage_code';
  34. /**
  35. * 添加时间获取器
  36. * @param $value
  37. * @return false|string
  38. */
  39. protected function getAddTimeAttr($value)
  40. {
  41. if ($value) return date('Y-m-d H:i:s', (int)$value);
  42. return '';
  43. }
  44. /**一对一关联
  45. * 关联订单信息
  46. * @return \think\model\relation\HasOne
  47. */
  48. public function orderId()
  49. {
  50. return $this->hasOne(StoreOrder::class, 'id', 'oid')->field(['id','order_id','pay_type','total_price','pay_price','paid','refund_status','staff_id', 'is_del', 'is_system_del']);
  51. }
  52. /**一对一关联
  53. * 关联桌码信息
  54. * @return \think\model\relation\HasOne
  55. */
  56. public function qrcode()
  57. {
  58. return $this->hasOne(TableQrcode::class, 'id', 'qrcode_id')->field(['id','cate_id','table_number','is_using','is_del']);
  59. }
  60. }