🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ <?php namespace app\api\controller\v1; use app\api\validate\IDMustBePostiveInt; use app\api\model\Banner as BannerModel; use app\lib\exception\BannerMissException; class Banner{ //获取指定id的banner信息 public function getBanner($id) { (new IDMustBePostiveInt())->goCheck(); $banner=BannerModel::with(['items','items.img'])->find($id); //隐藏字段 //$banner->hidden(['delete_time','update_time']); //只显示字段 $banner->visible(['id']); if(!$banner){ throw new BannerMissException(); } return $banner; } } ~~~ ![](https://box.kancloud.cn/b01ffe0f06fe47291129aa31ad7a30af_688x736.png) ![](https://box.kancloud.cn/2ad59905bad4d8235973e420df01f885_621x579.png)