1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace app\common\model;
- use think\Model;
- class ClientManageBlock extends Model
- {
- // 表名
- protected $table = 'client_manage_block';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
-
- // 追加属性
- protected $append = [
- 'type_text'
- ];
-
- protected static function init()
- {
- self::afterInsert(function ($row) {
- $pk = $row->getPk();
- $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
- });
- }
- public function getTypeList($page_id = null)
- {
- $result = [];
- switch ($page_id){
- case '1': //男频
- case '2': //女频
- $result = [
- '1' => '轮播',
- '2' => '横4',
- '3' => '竖4',
- '4' => '标题导航',
- '5' => '搜索',
- '6' => '块导航',
- '7' => '榜单',
- '8' => '最近阅读块',
- '11' => '运营活动位',
- //'12' => 'app内置书',
- ];
- break;
- case '3': //限免男频
- case '4': //限免女频
- $result = ['1' =>'轮播','2' =>'横4'];
- break;
- default:
- $result = [
- '1' => '轮播',
- '2' => '横4',
- '3' => '竖4',
- '4' => '标题导航',
- '5' => '搜索',
- '6' => '块导航',
- '7' => '榜单',
- '8' => '最近阅读块',
- '11' => '运营活动位',
- //'12' => 'app内置书',
- ];
- }
- return $result;
- }
- public function getTypeTextAttr($value, $data)
- {
- $value = $value ? $value : $data['type'];
- $list = $this->getTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- }
|