0 && !empty($coverImg)){ $data = ['cover_img' => $coverImg]; GoodsModel::where('id',$goodsId)->update($data); } if($goodsId > 0 && !empty($bannerImg)){ $banner = GoodsBannerModel::where('goods_id',$goodsId)->first(); if(empty($banner)){ $banner = new GoodsBanners(); $banner->goods_id = $goodsId; $banner->type = 1; $banner->created_at = time(); } $banner->path = $bannerImg; $banner->updated_at = time(); $banner->save(); } return $this->success('修改成功', '/goods_new'); } /** * Build a form here. */ public function form() { $id = $this->getKey(); $goods = GoodsModel::select('name')->find($id); $goodName = empty($goods->name)?'':$goods->name; $this->hidden('goods_id')->value($id); $this->image('cover_img','封面图')->url('ops/files')->help('商品名称:'.$goodName); $this->image('img_banner','轮播图')->url('ops/files'); } /** * The data of the form. * * @return array */ public function default() { return []; } }