Notifyuser.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. namespace app\admin\model\csminvite;
  3. use think\Model;
  4. class Notifyuser extends Model
  5. {
  6. // 表名
  7. protected $name = 'csminvite_notifyuser';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'userstatus_text',
  17. 'notifytime_text',
  18. 'firstseetime_text',
  19. 'lastseetime_text',
  20. 'registedtime_text',
  21. 'status_text'
  22. ];
  23. public function getUserstatusList()
  24. {
  25. return ['unnotify' => __('Userstatus unnotify'), 'nofitied' => __('Userstatus nofitied'), 'hassaw' => __('Userstatus hassaw'), 'registed' => __('Userstatus registed')];
  26. }
  27. public function getStatusList()
  28. {
  29. return ['normal' => __('Normal'), 'hidden' => __('Hidden')];
  30. }
  31. public function getUserstatusTextAttr($value, $data)
  32. {
  33. $value = $value ? $value : (isset($data['userstatus']) ? $data['userstatus'] : '');
  34. $list = $this->getUserstatusList();
  35. return isset($list[$value]) ? $list[$value] : '';
  36. }
  37. public function getNotifytimeTextAttr($value, $data)
  38. {
  39. $value = $value ? $value : (isset($data['notifytime']) ? $data['notifytime'] : '');
  40. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  41. }
  42. public function getFirstseetimeTextAttr($value, $data)
  43. {
  44. $value = $value ? $value : (isset($data['firstseetime']) ? $data['firstseetime'] : '');
  45. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  46. }
  47. public function getLastseetimeTextAttr($value, $data)
  48. {
  49. $value = $value ? $value : (isset($data['lastseetime']) ? $data['lastseetime'] : '');
  50. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  51. }
  52. public function getRegistedtimeTextAttr($value, $data)
  53. {
  54. $value = $value ? $value : (isset($data['registedtime']) ? $data['registedtime'] : '');
  55. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  56. }
  57. public function getStatusTextAttr($value, $data)
  58. {
  59. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  60. $list = $this->getStatusList();
  61. return isset($list[$value]) ? $list[$value] : '';
  62. }
  63. protected function setNotifytimeAttr($value)
  64. {
  65. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  66. }
  67. protected function setFirstseetimeAttr($value)
  68. {
  69. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  70. }
  71. protected function setLastseetimeAttr($value)
  72. {
  73. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  74. }
  75. protected function setRegistedtimeAttr($value)
  76. {
  77. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  78. }
  79. }