ReferralMany.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class ReferralMany extends Model
  5. {
  6. // 表名
  7. protected $table = 'referral_many';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. // 追加属性
  14. protected $append = [
  15. 'short_url_type_text',
  16. 'state_text'
  17. ];
  18. // 类型转换
  19. protected $type = [
  20. 'push_json' => 'json',
  21. ];
  22. public function getShortUrlTypeList()
  23. {
  24. return ['1' => '腾讯短连接', '2' => '微博短连接'];
  25. }
  26. public function getStateList()
  27. {
  28. return ['0' => '禁用', '1' => '正常'];
  29. }
  30. public function getShortUrlTypeTextAttr($value, $data)
  31. {
  32. $value = $value ? $value : $data['short_url_type'];
  33. $list = $this->getShortUrlTypeList();
  34. return isset($list[$value]) ? $list[$value] : '';
  35. }
  36. public function getStateTextAttr($value, $data)
  37. {
  38. $value = $value ? $value : $data['state'];
  39. $list = $this->getStateList();
  40. return isset($list[$value]) ? $list[$value] : '';
  41. }
  42. }