CustomUrl.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class CustomUrl extends Model
  5. {
  6. // 表名
  7. protected $table = 'custom_url';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. // 追加属性
  14. protected $append = [
  15. 'message_type_text',
  16. 'type_text',
  17. 'official_account_type_text',
  18. 'push_type_text'
  19. ];
  20. // public function customurlcollect()
  21. // {
  22. // return $this->belongsTo('CustomUrlCollect', 'id')->setEagerlyType(0);
  23. // }
  24. public function getMessageTypeList()
  25. {
  26. return ['0' => __('Message_type 0'),'1' => __('Message_type 1')];
  27. }
  28. public function getTypeList()
  29. {
  30. return ['0' => __('Type 0'),'1' => __('Type 1'),'2' => __('Type 2'),'3' => __('Type 3'),'4' => __('Type 4'),'5' => __('Type 5'),'6' => __('Type 6'),'7' => __('自动签到'),'8' => __('常用链接')];
  31. }
  32. public function getOfficialAccountTypeList()
  33. {
  34. return ['0' => __('Official_account_type 0'),'1' => __('Official_account_type 1')];
  35. }
  36. public function getPushTypeList()
  37. {
  38. return ['0' => __('Push_type 0'),'1' => __('Push_type 1')];
  39. }
  40. public function getMessageTypeTextAttr($value, $data)
  41. {
  42. $value = $value ? $value : $data['message_type'];
  43. $list = $this->getMessageTypeList();
  44. return isset($list[$value]) ? $list[$value] : '';
  45. }
  46. public function getTypeTextAttr($value, $data)
  47. {
  48. $value = $value ? $value : $data['type'];
  49. $list = $this->getTypeList();
  50. return isset($list[$value]) ? $list[$value] : '';
  51. }
  52. public function getOfficialAccountTypeTextAttr($value, $data)
  53. {
  54. $value = $value ? $value : $data['official_account_type'];
  55. $list = $this->getOfficialAccountTypeList();
  56. return isset($list[$value]) ? $list[$value] : '';
  57. }
  58. public function getPushTypeTextAttr($value, $data)
  59. {
  60. $value = $value ? $value : $data['push_type'];
  61. $list = $this->getPushTypeList();
  62. return isset($list[$value]) ? $list[$value] : '';
  63. }
  64. }