123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?php
- namespace app\common\model;
- use think\Model;
- class SpecialBlock extends Model
- {
- // 表名
- protected $table = 'special_block';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
-
- // 追加属性
- protected $append = [
- 'block_type_text',
- 'title_type_text',
- 'news_type_text',
- 'is_add_book_text',
- 'is_show_hot_text',
- 'go_method_text'
- ];
-
-
- public function getBlockTypeList()
- {
- return ['1' => __('Block_type 1'),'3' => __('Block_type 3'),'4' => __('Block_type 4'),'5' => __('Block_type 5')];
- }
- public function getTitleTypeList()
- {
- return ['1' => __('Title_type 1'),'2' => __('Title_type 2'),'3' => __('Title_type 3'),'4' => __('Title_type 4')];
- }
- public function getNewsTypeList()
- {
- return ['1' => __('News_type 1'),'2' => __('News_type 2'),'3' => __('News_type 3')];
- }
- public function getIsAddBookList()
- {
- return ['0' => __('Is_add_book 0'),'1' => __('Is_add_book 1')];
- }
- public function getIsShowHotList()
- {
- return ['0' => __('Is_show_hot 0'),'1' => __('Is_show_hot 1')];
- }
- public function getGoMethodList()
- {
- return ['1' => __('Go_method 1'),'2' => __('Go_method 2')];
- }
- public function getBlockTypeTextAttr($value, $data)
- {
- $value = $value ? $value : $data['block_type'];
- $list = $this->getBlockTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getTitleTypeTextAttr($value, $data)
- {
- $value = $value ? $value : $data['title_type'];
- $list = $this->getTitleTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getNewsTypeTextAttr($value, $data)
- {
- $value = $value ? $value : $data['news_type'];
- $list = $this->getNewsTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsAddBookTextAttr($value, $data)
- {
- $value = $value ? $value : $data['is_add_book'];
- $list = $this->getIsAddBookList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsShowHotTextAttr($value, $data)
- {
- $value = $value ? $value : $data['is_show_hot'];
- $list = $this->getIsShowHotList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getGoMethodTextAttr($value, $data)
- {
- $value = $value ? $value : $data['go_method'];
- $list = $this->getGoMethodList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- }
|