WechatSubscribeConfig.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class WechatSubscribeConfig extends BaseRwModel
  5. {
  6. // 表名
  7. protected $table = 'wechat_subscribe_config';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. // 追加属性
  14. protected $append = [
  15. 'type_text',
  16. 'status_text'
  17. ];
  18. public function getTypeList()
  19. {
  20. return ['default' => __('Type default'),'text' => __('Type text'),'news' => __('Type news')];
  21. }
  22. public function getStatusList()
  23. {
  24. return ['normal' => __('Status normal'),'hidden' => __('Status hidden')];
  25. }
  26. public function getTypeTextAttr($value, $data)
  27. {
  28. $value = $value ? $value : $data['type'];
  29. $list = $this->getTypeList();
  30. return isset($list[$value]) ? $list[$value] : '';
  31. }
  32. public function getStatusTextAttr($value, $data)
  33. {
  34. $value = $value ? $value : $data['status'];
  35. $list = $this->getStatusList();
  36. return isset($list[$value]) ? $list[$value] : '';
  37. }
  38. }