Banner.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Banner extends Model
  5. {
  6. // 表名
  7. protected $name = 'banner';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'integer';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'module_type_text',
  17. 'type_text',
  18. 'status_text'
  19. ];
  20. public function getModuleTypeList()
  21. {
  22. return ['user' => __('User'), 'massager' => __('Massager')];
  23. }
  24. public function getTypeList()
  25. {
  26. return ['app' => __('App'), 'web' => __('Web')];
  27. }
  28. public function getStatusList()
  29. {
  30. return ['hidden' => __('Hidden'), 'normal' => __('Normal')];
  31. }
  32. public function getModuleTypeTextAttr($value, $data)
  33. {
  34. $value = $value ? $value : (isset($data['module_type']) ? $data['module_type'] : '');
  35. $list = $this->getModuleTypeList();
  36. return isset($list[$value]) ? $list[$value] : '';
  37. }
  38. public function getTypeTextAttr($value, $data)
  39. {
  40. $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
  41. $list = $this->getTypeList();
  42. return isset($list[$value]) ? $list[$value] : '';
  43. }
  44. public function getStatusTextAttr($value, $data)
  45. {
  46. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  47. $list = $this->getStatusList();
  48. return isset($list[$value]) ? $list[$value] : '';
  49. }
  50. }