WorkGroupChatAuth.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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\work;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\model\concern\SoftDelete;
  15. /**
  16. * 企业微信自动拉群
  17. * Class WorkGroupChatAuth
  18. * @package app\model\work
  19. */
  20. class WorkGroupChatAuth extends BaseModel
  21. {
  22. use ModelTrait, SoftDelete;
  23. /**
  24. * @var string
  25. */
  26. protected $name = 'work_group_chat_auth';
  27. /**
  28. * @var string
  29. */
  30. protected $key = 'id';
  31. /**
  32. * @var string
  33. */
  34. protected $autoWriteTimestamp = 'int';
  35. /**
  36. * @param $value
  37. * @return false|string
  38. */
  39. public function setWelcomeWordsAttr($value)
  40. {
  41. return json_encode($value);
  42. }
  43. /**
  44. * @param $value
  45. * @return mixed
  46. */
  47. public function getWelcomeWordsAttr($value)
  48. {
  49. return json_decode($value, true);
  50. }
  51. /**
  52. * @param $value
  53. * @return false|string
  54. */
  55. public function setAdminUserAttr($value)
  56. {
  57. return json_encode($value);
  58. }
  59. /**
  60. * @param $value
  61. * @return mixed
  62. */
  63. public function getAdminUserAttr($value)
  64. {
  65. return json_decode($value, true);
  66. }
  67. /**
  68. * @param $value
  69. * @return false|string
  70. */
  71. public function setChatIdAttr($value)
  72. {
  73. return json_encode($value);
  74. }
  75. /**
  76. * @param $value
  77. * @return mixed
  78. */
  79. public function getChatIdAttr($value)
  80. {
  81. return json_decode($value, true);
  82. }
  83. /**
  84. * @param $value
  85. * @return false|string
  86. */
  87. public function setLabelAttr($value)
  88. {
  89. return json_encode($value);
  90. }
  91. /**
  92. * @param $value
  93. * @return mixed
  94. */
  95. public function getLabelAttr($value)
  96. {
  97. return json_decode($value, true);
  98. }
  99. /**
  100. * @param $query
  101. * @param $value
  102. */
  103. public function searchNameAttr($query, $value)
  104. {
  105. if ('' !== $value) {
  106. $query->whereLike('name', '%' . $value . '%');
  107. }
  108. }
  109. /**
  110. * @param $query
  111. * @param $value
  112. */
  113. public function searchCreateTimeAttr($query, $value)
  114. {
  115. if ('' !== $value) {
  116. $this->searchTimeAttr($query, $value, ['timeKey' => 'create_time']);
  117. }
  118. }
  119. }