SchoolNew.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.thinkphp.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: thinkphp <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\api\model;
  13. use app\common\model\SchoolNew as SchoolNewModel;
  14. /**
  15. * 学校新闻资讯模型类
  16. * Class SchoolNew
  17. * @package app\api\model
  18. */
  19. class SchoolNew extends SchoolNewModel
  20. {
  21. protected $globalScope = [''];
  22. /**
  23. * 隐藏字段
  24. * @var array
  25. */
  26. protected $hidden = [
  27. 'update_time'
  28. ];
  29. /**
  30. * 显示分类列表(有数量限制)
  31. * @param $schoolId
  32. * @param int $type
  33. * @param int $limitRow
  34. * @return array|mixed
  35. * @throws \think\db\exception\DataNotFoundException
  36. * @throws \think\db\exception\DbException
  37. * @throws \think\db\exception\ModelNotFoundException
  38. */
  39. public static function getShowList($schoolId, $type = 1, $limitRow = 0)
  40. {
  41. return parent::getShowList($schoolId, $type, $limitRow); // TODO: Change the autogenerated stub
  42. }
  43. /**
  44. * 详情
  45. * @param int $id
  46. * @return SchoolNew|array|null
  47. */
  48. public static function getDetail(int $id){
  49. $info = static::detail($id,['school']);
  50. if(isset($info['logo'])){
  51. $info['logo_preview'] = $info['logo']? getPreview($info['logo']) : '';
  52. }
  53. $info->hidden(['update_time','status']);
  54. if($info){
  55. self::setIncViews($id);
  56. }
  57. return $info;
  58. }
  59. /**
  60. * 访问量
  61. * @param $id
  62. */
  63. public static function setIncViews($id){
  64. (new static())->setInc(['news_id'=> $id], 'views', 1);
  65. }
  66. }