123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Lessonpackage extends Model
- {
-
-
- // 表名
- protected $table = 'lesson_package';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'is_show_text',
- 'buytimes_text',
- 'newuser_text',
- 'olduser_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 getBuytimesList()
- {
- return ['0' => __('Buytimes 0'), '1' => __('Buytimes 1')];
- }
- public function getNewuserList()
- {
- return ['0' => __('Newuser 0'), '1' => __('Newuser 1')];
- }
- public function getOlduserList()
- {
- return ['0' => __('Olduser 0'), '1' => __('Olduser 1')];
- }
- public function getTypeList()
- {
- return ['1' => __('Type 1'), '2' => __('Type 2')];
- }
- public function getGiftTypeList()
- {
- return ['1' => __('Type 1'), '2' => __('Type 2')];
- }
- 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 getBuytimesTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['buytimes']) ? $data['buytimes'] : '');
- $list = $this->getBuytimesList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getNewuserTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['newuser']) ? $data['newuser'] : '');
- $list = $this->getNewuserList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getOlduserTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['olduser']) ? $data['olduser'] : '');
- $list = $this->getOlduserList();
- 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 getGiftTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['gift_type']) ? $data['gift_type'] : '');
- $list = $this->getGiftTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- /*public function lessona()
- {
- return $this->belongsTo('Lesson', 'lesson_ids', 'id', [], 'LEFT')->setEagerlyType(0);
- }*/
- public function lessonb()
- {
- return $this->belongsTo('Lesson', 'gift_lesson_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|