TableQrcode.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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\table;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use app\model\other\Category;
  15. use app\model\store\SystemStore;
  16. use app\model\activity\collage\UserCollageCode;
  17. /**
  18. * 拼单Model
  19. * Class TableSeats
  20. * @package app\model\activity\table
  21. */
  22. class TableQrcode extends BaseModel
  23. {
  24. use ModelTrait;
  25. /**
  26. * 数据表主键
  27. * @var string
  28. */
  29. protected $pk = 'id';
  30. /**
  31. * 模型名称
  32. * @var string
  33. */
  34. protected $name = 'table_qrcode';
  35. /**
  36. * 添加时间获取器
  37. * @param $value
  38. * @return false|string
  39. */
  40. protected function getAddTimeAttr($value)
  41. {
  42. if ($value) return date('Y-m-d H:i:s', (int)$value);
  43. return '';
  44. }
  45. /**
  46. * 添加时间获取器
  47. * @param $value
  48. * @return false|string
  49. */
  50. protected function getOrderTimeAttr($value)
  51. {
  52. if ($value) return date('m-d H:i', (int)$value);
  53. return '';
  54. }
  55. /**一对一关联
  56. * 获取分类
  57. * @return \think\model\relation\HasOne
  58. */
  59. public function category()
  60. {
  61. return $this->hasOne(Category::class, 'id', 'cate_id')->where(['group' => 6, 'type' => 1])->field(['id', 'name']);
  62. }
  63. /**一对一关联
  64. * 获取门店名称
  65. * @return \think\model\relation\HasOne
  66. */
  67. public function storeName()
  68. {
  69. return $this->hasOne(SystemStore::class, 'id', 'store_id')->field(['id','name as storeName']);
  70. }
  71. /**一对一关联
  72. * 获取桌码记录信息
  73. * @return \think\model\relation\HasOne
  74. */
  75. public function collateCode()
  76. {
  77. return $this->hasOne(UserCollageCode::class, 'qrcode_id', 'id')->field(['qrcode_id','serial_number','number_diners']);
  78. }
  79. }