// +---------------------------------------------------------------------- declare (strict_types=1); namespace app\api\model; use app\common\model\SchoolNew as SchoolNewModel; /** * 学校新闻资讯模型类 * Class SchoolNew * @package app\api\model */ class SchoolNew extends SchoolNewModel { protected $globalScope = ['']; /** * 隐藏字段 * @var array */ protected $hidden = [ 'update_time' ]; /** * 显示分类列表(有数量限制) * @param $schoolId * @param int $type * @param int $limitRow * @return array|mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function getShowList($schoolId, $type = 1, $limitRow = 0) { return parent::getShowList($schoolId, $type, $limitRow); // TODO: Change the autogenerated stub } /** * 详情 * @param int $id * @return SchoolNew|array|null */ public static function getDetail(int $id){ $info = static::detail($id,['school']); if(isset($info['logo'])){ $info['logo_preview'] = $info['logo']? getPreview($info['logo']) : ''; } $info->hidden(['update_time','status']); if($info){ self::setIncViews($id); } return $info; } /** * 访问量 * @param $id */ public static function setIncViews($id){ (new static())->setInc(['news_id'=> $id], 'views', 1); } }