WorkGroupMsgSendResult.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. /**
  15. *
  16. * Class WorkGroupMsgSendResult
  17. * @package app\model\work
  18. */
  19. class WorkGroupMsgSendResult extends BaseModel
  20. {
  21. use ModelTrait;
  22. /**
  23. * @var string
  24. */
  25. protected $name = 'work_group_msg_send_result';
  26. /**
  27. * @var string
  28. */
  29. protected $key = 'id';
  30. /**
  31. * @var string
  32. */
  33. protected $autoWriteTimestamp = 'int';
  34. /**
  35. * @return \think\model\relation\HasOne
  36. */
  37. public function client()
  38. {
  39. return $this->hasOne(WorkClient::class, 'external_userid', 'external_userid')
  40. ->field(['external_userid', 'name'])
  41. ->bind(['name' => 'name']);
  42. }
  43. public function chat()
  44. {
  45. return $this->hasOne(WorkGroupChat::class,'chat_id','chat_id');
  46. }
  47. /**
  48. * @param $query
  49. * @param $value
  50. */
  51. public function searchMsgIdAttr($query, $value)
  52. {
  53. if (is_array($value)) {
  54. $query->whereIn('msg_id', $value);
  55. } else {
  56. $query->where('msg_id', $value);
  57. }
  58. }
  59. /**
  60. * @param $query
  61. * @param $value
  62. */
  63. public function searchStatusAttr($query, $value)
  64. {
  65. if ('' !== $value) {
  66. if (is_array($value)) {
  67. $query->whereIn('status', $value);
  68. } else {
  69. $query->where('status', $value);
  70. }
  71. }
  72. }
  73. /**
  74. * @param $value
  75. * @return false|string
  76. */
  77. public function getSendTimeAttr($value)
  78. {
  79. return $value ? date('Y-m-d H:i:s', $value) : '';
  80. }
  81. }