Party.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. namespace app\admin\model\party;
  3. use think\Model;
  4. class Party extends Model
  5. {
  6. // 表名
  7. protected $name = 'party';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'is_cool_text',
  17. 'room_type_text',
  18. 'is_online_text',
  19. 'status_text',
  20. 'is_recommend_text',
  21. 'is_screen_text',
  22. 'on_model_text'
  23. ];
  24. public function getIsCoolList()
  25. {
  26. return ['0' => __('Is_cool 0'), '1' => __('Is_cool 1')];
  27. }
  28. public function getRoomTypeList()
  29. {
  30. return ['1' => __('Room_type 1'), '2' => __('Room_type 2')];
  31. }
  32. public function getIsOnlineList()
  33. {
  34. return ['1' => __('Is_online 1'), '0' => __('Is_online 0')];
  35. }
  36. public function getStatusList()
  37. {
  38. return ['-1' => __('Status -1'), '1' => __('Status 1')];
  39. }
  40. public function getIsRecommendList()
  41. {
  42. return ['1' => __('Is_recommend 1'), '0' => __('Is_recommend 0')];
  43. }
  44. public function getIsCloseList()
  45. {
  46. return ['1' => __('Is_close 1'), '0' => __('Is_close 0')];
  47. }
  48. public function getIsScreenList()
  49. {
  50. return ['1' => __('Is_screen 1'), '0' => __('Is_screen 0')];
  51. }
  52. public function getOnModelList()
  53. {
  54. return ['1' => __('On_model 1'), '2' => __('On_model 2')];
  55. }
  56. public function getIsCoolTextAttr($value, $data)
  57. {
  58. $value = $value ? $value : (isset($data['is_cool']) ? $data['is_cool'] : '');
  59. $list = $this->getIsCoolList();
  60. return isset($list[$value]) ? $list[$value] : '';
  61. }
  62. public function getRoomTypeTextAttr($value, $data)
  63. {
  64. $value = $value ? $value : (isset($data['room_type']) ? $data['room_type'] : '');
  65. $list = $this->getRoomTypeList();
  66. return isset($list[$value]) ? $list[$value] : '';
  67. }
  68. public function getIsOnlineTextAttr($value, $data)
  69. {
  70. $value = $value ? $value : (isset($data['is_online']) ? $data['is_online'] : '');
  71. $list = $this->getIsOnlineList();
  72. return isset($list[$value]) ? $list[$value] : '';
  73. }
  74. public function getStatusTextAttr($value, $data)
  75. {
  76. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  77. $list = $this->getStatusList();
  78. return isset($list[$value]) ? $list[$value] : '';
  79. }
  80. public function getIsRecommendTextAttr($value, $data)
  81. {
  82. $value = $value ? $value : (isset($data['is_recommend']) ? $data['is_recommend'] : '');
  83. $list = $this->getIsRecommendList();
  84. return isset($list[$value]) ? $list[$value] : '';
  85. }
  86. public function getIsScreenTextAttr($value, $data)
  87. {
  88. $value = $value ? $value : (isset($data['is_screen']) ? $data['is_screen'] : '');
  89. $list = $this->getIsScreenList();
  90. return isset($list[$value]) ? $list[$value] : '';
  91. }
  92. public function getOnModelTextAttr($value, $data)
  93. {
  94. $value = $value ? $value : (isset($data['on_model']) ? $data['on_model'] : '');
  95. $list = $this->getOnModelList();
  96. return isset($list[$value]) ? $list[$value] : '';
  97. }
  98. public function user()
  99. {
  100. return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  101. }
  102. //关联派对类型表
  103. public function partyType()
  104. {
  105. return $this->hasOne(Type::class, 'id', 'party_type',[],'LEFT');
  106. }
  107. }