| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Banner extends Model
- {
-
-
- // 表名
- protected $name = 'banner';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'integer';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'module_type_text',
- 'type_text',
- 'status_text'
- ];
-
-
- public function getModuleTypeList()
- {
- return ['user' => __('User'), 'massager' => __('Massager')];
- }
- public function getTypeList()
- {
- return ['app' => __('App'), 'web' => __('Web')];
- }
- public function getStatusList()
- {
- return ['hidden' => __('Hidden'), 'normal' => __('Normal')];
- }
- public function getModuleTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['module_type']) ? $data['module_type'] : '');
- $list = $this->getModuleTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
- $list = $this->getTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- }
|