1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Gift extends Model
- {
-
-
- // 表名
- protected $name = 'gift';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'is_show_text',
- 'is_vip_text'
- ];
-
- protected static function init()
- {
- self::afterInsert(function ($row) {
- $pk = $row->getPk();
- $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
- });
- }
-
- public function getIsShowList()
- {
- return ['1' => __('Is_show 1'), '0' => __('Is_show 0')];
- }
- public function getIsVipList()
- {
- return ['1' => __('Is_vip 1'), '0' => __('Is_vip 0')];
- }
- public function getIsShowTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_show']) ? $data['is_show'] : '');
- $list = $this->getIsShowList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsVipTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_vip']) ? $data['is_vip'] : '');
- $list = $this->getIsVipList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- }
|