12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace app\admin\model\gift;
- use think\Model;
- class Gift extends Model
- {
-
-
- // 表名
- protected $name = 'gift';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'is_big_text',
- 'complex_text',
- 'timelimit_text'
- ];
-
-
- public function getIsBigList()
- {
- return ['0' => __('Is_big 0'), '1' => __('Is_big 1')];
- }
- public function getTypeList()
- {
- return ['0' => __('Type 0'), '1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3'), '4' => __('Type 4')];
- }
-
- public function getComplexList()
- {
- return ['1' => __('Complex 1'), '0' => __('Complex 0')];
- }
- public function getBoxtypeList()
- {
- return ['0' => __('非宝箱礼物'), '1' => __('青铜宝箱'), '2' => __('黄金宝箱'), '3' => __('荣耀黄金宝箱'), '4' => __('荣耀紫金宝箱')];
- }
- public function getTimelimitList()
- {
- return ['1' => __('Timelimit 1'), '0' => __('Timelimit 0')];
- }
- public function getTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
- $list = $this->getTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsBigTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_big']) ? $data['is_big'] : '');
- $list = $this->getIsBigList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getComplexTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['complex']) ? $data['complex'] : '');
- $list = $this->getComplexList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getTimelimitTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['timelimit']) ? $data['timelimit'] : '');
- $list = $this->getTimelimitList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function gifttype()
- {
- return $this->belongsTo('app\admin\model\gift\Type', 'type', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|