Feedback.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Feedback extends Model
  5. {
  6. // 表名
  7. protected $table = 'feedback';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'integer';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'status_text',
  17. 'notice_status_text',
  18. 'is_hidden_text'
  19. ];
  20. public function getStatusList()
  21. {
  22. return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
  23. }
  24. public function getNoticeStatusList()
  25. {
  26. return ['0' => __('Notice_status 0'), '1' => __('Notice_status 1')];
  27. }
  28. public function getIsHiddenList()
  29. {
  30. return ['0' => __('Is_hidden 0'), '1' => __('Is_hidden 1')];
  31. }
  32. public function getStatusTextAttr($value, $data)
  33. {
  34. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  35. $list = $this->getStatusList();
  36. return isset($list[$value]) ? $list[$value] : '';
  37. }
  38. public function getNoticeStatusTextAttr($value, $data)
  39. {
  40. $value = $value ? $value : (isset($data['notice_status']) ? $data['notice_status'] : '');
  41. $list = $this->getNoticeStatusList();
  42. return isset($list[$value]) ? $list[$value] : '';
  43. }
  44. public function getIsHiddenTextAttr($value, $data)
  45. {
  46. $value = $value ? $value : (isset($data['is_hidden']) ? $data['is_hidden'] : '');
  47. $list = $this->getIsHiddenList();
  48. return isset($list[$value]) ? $list[$value] : '';
  49. }
  50. public function user()
  51. {
  52. return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  53. }
  54. }