SpecialBlock.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class SpecialBlock extends Model
  5. {
  6. // 表名
  7. protected $table = 'special_block';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. // 追加属性
  14. protected $append = [
  15. 'block_type_text',
  16. 'title_type_text',
  17. 'news_type_text',
  18. 'is_add_book_text',
  19. 'is_show_hot_text',
  20. 'go_method_text'
  21. ];
  22. public function getBlockTypeList()
  23. {
  24. return ['1' => __('Block_type 1'),'3' => __('Block_type 3'),'4' => __('Block_type 4'),'5' => __('Block_type 5')];
  25. }
  26. public function getTitleTypeList()
  27. {
  28. return ['1' => __('Title_type 1'),'2' => __('Title_type 2'),'3' => __('Title_type 3'),'4' => __('Title_type 4')];
  29. }
  30. public function getNewsTypeList()
  31. {
  32. return ['1' => __('News_type 1'),'2' => __('News_type 2'),'3' => __('News_type 3')];
  33. }
  34. public function getIsAddBookList()
  35. {
  36. return ['0' => __('Is_add_book 0'),'1' => __('Is_add_book 1')];
  37. }
  38. public function getIsShowHotList()
  39. {
  40. return ['0' => __('Is_show_hot 0'),'1' => __('Is_show_hot 1')];
  41. }
  42. public function getGoMethodList()
  43. {
  44. return ['1' => __('Go_method 1'),'2' => __('Go_method 2')];
  45. }
  46. public function getBlockTypeTextAttr($value, $data)
  47. {
  48. $value = $value ? $value : $data['block_type'];
  49. $list = $this->getBlockTypeList();
  50. return isset($list[$value]) ? $list[$value] : '';
  51. }
  52. public function getTitleTypeTextAttr($value, $data)
  53. {
  54. $value = $value ? $value : $data['title_type'];
  55. $list = $this->getTitleTypeList();
  56. return isset($list[$value]) ? $list[$value] : '';
  57. }
  58. public function getNewsTypeTextAttr($value, $data)
  59. {
  60. $value = $value ? $value : $data['news_type'];
  61. $list = $this->getNewsTypeList();
  62. return isset($list[$value]) ? $list[$value] : '';
  63. }
  64. public function getIsAddBookTextAttr($value, $data)
  65. {
  66. $value = $value ? $value : $data['is_add_book'];
  67. $list = $this->getIsAddBookList();
  68. return isset($list[$value]) ? $list[$value] : '';
  69. }
  70. public function getIsShowHotTextAttr($value, $data)
  71. {
  72. $value = $value ? $value : $data['is_show_hot'];
  73. $list = $this->getIsShowHotList();
  74. return isset($list[$value]) ? $list[$value] : '';
  75. }
  76. public function getGoMethodTextAttr($value, $data)
  77. {
  78. $value = $value ? $value : $data['go_method'];
  79. $list = $this->getGoMethodList();
  80. return isset($list[$value]) ? $list[$value] : '';
  81. }
  82. }