Giftuserdongtai.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Giftuserdongtai extends Model
  5. {
  6. // 表名
  7. protected $name = 'gift_user_dongtai';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = false;
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'wallettype_text'
  17. ];
  18. public function getWallettypeList()
  19. {
  20. return ['1' => __('Wallettype 1'), '2' => __('Wallettype 2')];
  21. }
  22. public function getWallettypeTextAttr($value, $data)
  23. {
  24. $value = $value ? $value : (isset($data['wallettype']) ? $data['wallettype'] : '');
  25. $list = $this->getWallettypeList();
  26. return isset($list[$value]) ? $list[$value] : '';
  27. }
  28. public function user()
  29. {
  30. return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  31. }
  32. public function userto()
  33. {
  34. return $this->belongsTo('User', 'user_to_id', 'id', [], 'LEFT')->setEagerlyType(0);
  35. }
  36. public function gift()
  37. {
  38. return $this->belongsTo('Gift', 'gift_id', 'id', [], 'LEFT')->setEagerlyType(0);
  39. }
  40. public function topicdongtai()
  41. {
  42. return $this->belongsTo('Topicdongtai', 'dt_id', 'id', [], 'LEFT')->setEagerlyType(0);
  43. }
  44. }