Postbackrules.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class Postbackrules extends Model
  5. {
  6. // 表名
  7. protected $table = 'postback_rules';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. // 追加属性
  14. protected $append = [
  15. 'state_text',
  16. 'type_text'
  17. ];
  18. public function getStateList()
  19. {
  20. return ['show' => __('State show'), 'hide' => __('State hide')];
  21. }
  22. public function getTypeList()
  23. {
  24. return ['tout' => __('Type tout'), 'guangdt' => __('Type guangdt'), 'uc' => "uc"];
  25. }
  26. public function getStateTextAttr($value, $data)
  27. {
  28. $value = $value ? $value : $data['state'];
  29. $list = $this->getStateList();
  30. return isset($list[$value]) ? $list[$value] : '';
  31. }
  32. public function getTypeTextAttr($value, $data)
  33. {
  34. $value = $value ? $value : $data['type'];
  35. $list = $this->getTypeList();
  36. return isset($list[$value]) ? $list[$value] : '';
  37. }
  38. }