WorkGroupMsgTask.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace app\model\work;
  3. use crmeb\basic\BaseModel;
  4. use crmeb\traits\ModelTrait;
  5. /**
  6. * Class WorkGroupMsgTask
  7. * @package app\model\work
  8. */
  9. class WorkGroupMsgTask extends BaseModel
  10. {
  11. use ModelTrait;
  12. /**
  13. * @var string
  14. */
  15. protected $name = 'work_group_msg_task';
  16. /**
  17. * @var string
  18. */
  19. protected $pk = 'id';
  20. /**
  21. * @var bool
  22. */
  23. protected $autoWriteTimestamp = false;
  24. /**
  25. * @return \think\model\relation\HasOne
  26. */
  27. public function member()
  28. {
  29. return $this->hasOne(WorkMember::class, 'userid', 'userid')
  30. ->field(['userid', 'name'])
  31. ->bind(['name' => 'name']);
  32. }
  33. /**
  34. * @param $value
  35. * @return false|string
  36. */
  37. public function getSendTimeAttr($value)
  38. {
  39. return $value ? date('Y-m-d H:i:s', $value) : '';
  40. }
  41. /**
  42. * @param $value
  43. * @return false|string
  44. */
  45. public function getCreateTimeAttr($value)
  46. {
  47. return $value ? date('Y-m-d H:i:s', $value) : '';
  48. }
  49. /**
  50. * @return \think\model\relation\HasOne
  51. */
  52. public function sendResult()
  53. {
  54. return $this->hasOne(WorkGroupMsgSendResult::class, 'userid', 'userid');
  55. }
  56. /**
  57. * @param $query
  58. * @param $value
  59. */
  60. public function searchMsgIdAttr($query, $value)
  61. {
  62. if (is_array($value)) {
  63. $query->whereIn('msg_id', $value);
  64. } else {
  65. $query->where('msg_id', $value);
  66. }
  67. }
  68. /**
  69. * @param $query
  70. * @param $value
  71. */
  72. public function searchStatusAttr($query, $value)
  73. {
  74. if ('' !== $value) {
  75. $query->where('status', $value);
  76. }
  77. }
  78. }