Feedback.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace app\admin\model\system;
  3. use think\Model;
  4. class Feedback extends Model
  5. {
  6. // 表名
  7. protected $name = 'system_feedback';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'integer';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'type_text',
  17. 'relation_type_text',
  18. 'status_text'
  19. ];
  20. public function getTypeList()
  21. {
  22. return ['feedback' => __('Feedback'), 'complaint' => __('Complaint')];
  23. }
  24. public function getRelationTypeList()
  25. {
  26. return ['platform' => __('Platform'), 'agency' => __('Agency'), 'store' => __('Store'), 'massager' => __('Massager'), 'user' => __('User'), 'other' => __('Other')];
  27. }
  28. public function getStatusList()
  29. {
  30. return ['default' => __('Default'), 'dispose' => __('Dispose'), 'refuse' => __('Refuse')];
  31. }
  32. public function getTypeTextAttr($value, $data)
  33. {
  34. $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
  35. $list = $this->getTypeList();
  36. return isset($list[$value]) ? $list[$value] : '';
  37. }
  38. public function getRelationTypeTextAttr($value, $data)
  39. {
  40. $value = $value ? $value : (isset($data['relation_type']) ? $data['relation_type'] : '');
  41. $list = $this->getRelationTypeList();
  42. return isset($list[$value]) ? $list[$value] : '';
  43. }
  44. public function getStatusTextAttr($value, $data)
  45. {
  46. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  47. $list = $this->getStatusList();
  48. return isset($list[$value]) ? $list[$value] : '';
  49. }
  50. public function user()
  51. {
  52. return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  53. }
  54. public function massager()
  55. {
  56. return $this->belongsTo('app\admin\model\Massager', 'massager_id', 'id', [], 'LEFT')->setEagerlyType(0);
  57. }
  58. public function admin()
  59. {
  60. return $this->belongsTo('app\admin\model\Admin', 'agency_id', 'id', [], 'LEFT')->setEagerlyType(0);
  61. }
  62. }