WechatResponse.php 736 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class WechatResponse extends BaseRwModel
  5. {
  6. // 自动写入时间戳字段
  7. protected $autoWriteTimestamp = 'int';
  8. // 定义时间戳字段名
  9. protected $createTime = 'createtime';
  10. protected $updateTime = 'updatetime';
  11. // 追加属性
  12. protected $append = [
  13. 'type_text',
  14. ];
  15. public function getTypeList()
  16. {
  17. return ['text' => '文本', 'image' => '图片', 'news' => '图文'];
  18. }
  19. public function getTypeTextAttr($value, $data)
  20. {
  21. $value = $value ? $value : $data['type'];
  22. $list = $this->getTypeList();
  23. return isset($list[$value]) ? $list[$value] : '';
  24. }
  25. }