Activepeoplemodify.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Activepeoplemodify extends Model
  5. {
  6. // 表名
  7. protected $name = 'active_people_modify';
  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. ];
  21. public function getCoupontypeList()
  22. {
  23. return ['1' => __('Coupontype 1'), '2' => __('Coupontype 2')];
  24. }
  25. public function getIsFreeList()
  26. {
  27. return ['0' => __('Is_free 0'), '1' => __('Is_free 1')];
  28. }
  29. public function getIsSelfList()
  30. {
  31. return ['0' => __('Is_self 0'), '1' => __('Is_self 1')];
  32. }
  33. public function getStatusList()
  34. {
  35. return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
  36. }
  37. public function getCoupontypeTextAttr($value, $data)
  38. {
  39. $value = $value ? $value : (isset($data['coupontype']) ? $data['coupontype'] : '');
  40. $list = $this->getCoupontypeList();
  41. return isset($list[$value]) ? $list[$value] : '';
  42. }
  43. public function getIsFreeTextAttr($value, $data)
  44. {
  45. $value = $value ? $value : (isset($data['is_free']) ? $data['is_free'] : '');
  46. $list = $this->getIsFreeList();
  47. return isset($list[$value]) ? $list[$value] : '';
  48. }
  49. public function getIsSelfTextAttr($value, $data)
  50. {
  51. $value = $value ? $value : (isset($data['is_self']) ? $data['is_self'] : '');
  52. $list = $this->getIsSelfList();
  53. return isset($list[$value]) ? $list[$value] : '';
  54. }
  55. public function getStatusTextAttr($value, $data)
  56. {
  57. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  58. $list = $this->getStatusList();
  59. return isset($list[$value]) ? $list[$value] : '';
  60. }
  61. public function active()
  62. {
  63. return $this->belongsTo('Active', 'active_id', 'id', [], 'LEFT')->setEagerlyType(0);
  64. }
  65. public function activeorder()
  66. {
  67. return $this->belongsTo('Activeorder', 'order_id', 'id', [], 'LEFT')->setEagerlyType(0);
  68. }
  69. public function activepeople()
  70. {
  71. return $this->belongsTo('Activepeople', 'people_id', 'id', [], 'LEFT')->setEagerlyType(0);
  72. }
  73. public function user()
  74. {
  75. return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  76. }
  77. }