Msgtplchannel.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\admin\model\csmadmin;
  3. use think\Model;
  4. class Msgtplchannel extends Model
  5. {
  6. // 表名
  7. protected $name = 'csmadmin_msgtplchannel';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'channel_text',
  17. 'status_text'
  18. ];
  19. public function getChannelList()
  20. {
  21. return ['web' => __('Channel web'), 'email' => __('Channel email'), 'sms' => __('Channel sms'), 'dingtalk' => __('Channel dingtalk')];
  22. }
  23. public function getStatusList()
  24. {
  25. return ['normal' => __('Normal'), 'hidden' => __('Hidden')];
  26. }
  27. public function getChannelTextAttr($value, $data)
  28. {
  29. $value = $value ? $value : (isset($data['channel']) ? $data['channel'] : '');
  30. $list = $this->getChannelList();
  31. return isset($list[$value]) ? $list[$value] : '';
  32. }
  33. public function getStatusTextAttr($value, $data)
  34. {
  35. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  36. $list = $this->getStatusList();
  37. return isset($list[$value]) ? $list[$value] : '';
  38. }
  39. }