12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Videocate extends Model
- {
-
-
- // 表名
- protected $name = 'video_cate';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'status_text',
- 'showtype_text',
- 'is_zhuanti_text'
- ];
-
- protected static function init()
- {
- self::afterInsert(function ($row) {
- $pk = $row->getPk();
- $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
- });
- }
-
- public function getStatusList()
- {
- return ['0' => __('Status 0'), '1' => __('Status 1')];
- }
- public function getShowtypeList()
- {
- return ['1' => __('Showtype 1'), '2' => __('Showtype 2'), '3' => __('Showtype 3'), '4' => __('Showtype 4'), '5' => __('Showtype 5'), '6' => __('Showtype 6'), '7' => __('Showtype 7'), '8' => __('Showtype 8'), '9' => __('Showtype 9')];
- }
- public function getIsZhuantiList()
- {
- return ['1' => __('Is_zhuanti 1'), '0' => __('Is_zhuanti 0')];
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getShowtypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['showtype']) ? $data['showtype'] : '');
- $list = $this->getShowtypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsZhuantiTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_zhuanti']) ? $data['is_zhuanti'] : '');
- $list = $this->getIsZhuantiList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- }
|