Topicdongtai.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Topicdongtai extends Model
  5. {
  6. // 表名
  7. protected $name = 'topic_dongtai';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'is_hidden_text',
  17. 'is_show_real_text',
  18. 'type_text',
  19. 'auit_status_text'
  20. ];
  21. public function getIsHiddenList()
  22. {
  23. return ['1' => __('Is_hidden 1'), '0' => __('Is_hidden 0')];
  24. }
  25. public function getIsShowRealList()
  26. {
  27. return ['0' => __('Is_show_real 0'), '1' => __('Is_show_real 1')];
  28. }
  29. public function getTypeList()
  30. {
  31. return ['0' => __('Type 0'), '1' => __('Type 1'), '2' => __('Type 2')];
  32. }
  33. public function getAuitStatusList()
  34. {
  35. return ['0' => __('Auit_status 0'), '1' => __('Auit_status 1'), '2' => __('Auit_status 2')];
  36. }
  37. public function getIsHiddenTextAttr($value, $data)
  38. {
  39. $value = $value ? $value : (isset($data['is_hidden']) ? $data['is_hidden'] : '');
  40. $list = $this->getIsHiddenList();
  41. return isset($list[$value]) ? $list[$value] : '';
  42. }
  43. public function getIsShowRealTextAttr($value, $data)
  44. {
  45. $value = $value ? $value : (isset($data['is_show_real']) ? $data['is_show_real'] : '');
  46. $list = $this->getIsShowRealList();
  47. return isset($list[$value]) ? $list[$value] : '';
  48. }
  49. public function getTypeTextAttr($value, $data)
  50. {
  51. $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
  52. $list = $this->getTypeList();
  53. return isset($list[$value]) ? $list[$value] : '';
  54. }
  55. public function getAuitStatusTextAttr($value, $data)
  56. {
  57. $value = $value ? $value : (isset($data['auit_status']) ? $data['auit_status'] : '');
  58. $list = $this->getAuitStatusList();
  59. return isset($list[$value]) ? $list[$value] : '';
  60. }
  61. public function topichub()
  62. {
  63. return $this->belongsTo('Topichub', 'topic_id', 'id', [], 'LEFT')->setEagerlyType(0);
  64. }
  65. public function user()
  66. {
  67. return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  68. }
  69. }