ClientManageBlock.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class ClientManageBlock extends Model
  5. {
  6. // 表名
  7. protected $table = 'client_manage_block';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. // 追加属性
  14. protected $append = [
  15. 'type_text'
  16. ];
  17. protected static function init()
  18. {
  19. self::afterInsert(function ($row) {
  20. $pk = $row->getPk();
  21. $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
  22. });
  23. }
  24. public function getTypeList($page_id = null)
  25. {
  26. $result = [];
  27. switch ($page_id){
  28. case '1': //男频
  29. case '2': //女频
  30. $result = [
  31. '1' => '轮播',
  32. '2' => '横4',
  33. '3' => '竖4',
  34. '4' => '标题导航',
  35. '5' => '搜索',
  36. '6' => '块导航',
  37. '7' => '榜单',
  38. '8' => '最近阅读块',
  39. '11' => '运营活动位',
  40. //'12' => 'app内置书',
  41. ];
  42. break;
  43. case '3': //限免男频
  44. case '4': //限免女频
  45. $result = ['1' =>'轮播','2' =>'横4'];
  46. break;
  47. default:
  48. $result = [
  49. '1' => '轮播',
  50. '2' => '横4',
  51. '3' => '竖4',
  52. '4' => '标题导航',
  53. '5' => '搜索',
  54. '6' => '块导航',
  55. '7' => '榜单',
  56. '8' => '最近阅读块',
  57. '11' => '运营活动位',
  58. //'12' => 'app内置书',
  59. ];
  60. }
  61. return $result;
  62. }
  63. public function getTypeTextAttr($value, $data)
  64. {
  65. $value = $value ? $value : $data['type'];
  66. $list = $this->getTypeList();
  67. return isset($list[$value]) ? $list[$value] : '';
  68. }
  69. }