WechatQrcode.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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\wechat;
  12. use app\model\user\User;
  13. use crmeb\basic\BaseModel;
  14. use crmeb\traits\ModelTrait;
  15. /**
  16. * 关键词
  17. * Class WechatReply
  18. * @package app\model\wechat
  19. */
  20. class WechatQrcode extends BaseModel
  21. {
  22. use ModelTrait;
  23. /**
  24. * 数据表主键
  25. * @var string
  26. */
  27. protected $pk = 'id';
  28. /**
  29. * 模型名称
  30. * @var string
  31. */
  32. protected $name = 'wechat_qrcode';
  33. /**
  34. * 添加时间获取器
  35. * @param $value
  36. * @return false|string
  37. */
  38. protected function getAddTimeAttr($value)
  39. {
  40. if ($value) return date('Y-m-d H:i:s', (int)$value);
  41. return '';
  42. }
  43. public function user()
  44. {
  45. return $this->hasOne(User::class, 'uid', 'uid')->bind(['nickname', 'avatar']);
  46. }
  47. public function record()
  48. {
  49. return $this->hasOne(WechatQrcodeRecord::class, 'qid', 'id');
  50. }
  51. public function searchUidAttr($query, $value)
  52. {
  53. if ($value != '') $query->where('uid', $value);
  54. }
  55. public function searchCateIdAttr($query, $value)
  56. {
  57. if ($value != '') $query->where('cate_id', $value);
  58. }
  59. public function searchNameAttr($query, $value)
  60. {
  61. if ($value != '') $query->whereLike('id|uid|name', '%' . $value . '%');
  62. }
  63. public function searchIsDelAttr($query, $value)
  64. {
  65. if ($value !== '') $query->where('is_del', $value);
  66. }
  67. }