Activepeople.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Activepeople extends Model
  5. {
  6. // 表名
  7. protected $name = 'active_people';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'coupontype_text',
  17. 'is_free_text',
  18. 'is_self_text',
  19. 'status_text',
  20. 'modifystatus_text'
  21. ];
  22. public function getCoupontypeList()
  23. {
  24. return ['1' => __('Coupontype 1'), '2' => __('Coupontype 2')];
  25. }
  26. public function getIsFreeList()
  27. {
  28. return ['0' => __('Is_free 0'), '1' => __('Is_free 1')];
  29. }
  30. public function getIsSelfList()
  31. {
  32. return ['0' => __('Is_self 0'), '1' => __('Is_self 1')];
  33. }
  34. public function getStatusList()
  35. {
  36. return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3')];
  37. }
  38. public function getModifystatusList()
  39. {
  40. return ['0' => __('Modifystatus 0'), '1' => __('Modifystatus 1')];
  41. }
  42. public function getCoupontypeTextAttr($value, $data)
  43. {
  44. $value = $value ? $value : (isset($data['coupontype']) ? $data['coupontype'] : '');
  45. $list = $this->getCoupontypeList();
  46. return isset($list[$value]) ? $list[$value] : '';
  47. }
  48. public function getIsFreeTextAttr($value, $data)
  49. {
  50. $value = $value ? $value : (isset($data['is_free']) ? $data['is_free'] : '');
  51. $list = $this->getIsFreeList();
  52. return isset($list[$value]) ? $list[$value] : '';
  53. }
  54. public function getIsSelfTextAttr($value, $data)
  55. {
  56. $value = $value ? $value : (isset($data['is_self']) ? $data['is_self'] : '');
  57. $list = $this->getIsSelfList();
  58. return isset($list[$value]) ? $list[$value] : '';
  59. }
  60. public function getStatusTextAttr($value, $data)
  61. {
  62. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  63. $list = $this->getStatusList();
  64. return isset($list[$value]) ? $list[$value] : '';
  65. }
  66. public function getModifystatusTextAttr($value, $data)
  67. {
  68. $value = $value ? $value : (isset($data['modifystatus']) ? $data['modifystatus'] : '');
  69. $list = $this->getModifystatusList();
  70. return isset($list[$value]) ? $list[$value] : '';
  71. }
  72. public function active()
  73. {
  74. return $this->belongsTo('Active', 'active_id', 'id', [], 'LEFT')->setEagerlyType(0);
  75. }
  76. public function activeorder()
  77. {
  78. return $this->belongsTo('Activeorder', 'order_id', 'id', [], 'LEFT')->setEagerlyType(0);
  79. }
  80. public function user()
  81. {
  82. return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  83. }
  84. }