From 26cd875b524c64c27d62852939240c8d8cb4267b Mon Sep 17 00:00:00 2001 From: anyv <anyu@bronet.cn> Date: Fri, 31 May 2019 16:23:24 +0800 Subject: [PATCH] 商品编辑 --- app/admin/controller/GoodsController.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/admin/controller/GoodsController.php b/app/admin/controller/GoodsController.php index 00ba640..83a212b 100644 --- a/app/admin/controller/GoodsController.php +++ b/app/admin/controller/GoodsController.php @@ -108,11 +108,15 @@ class GoodsController extends AdminBaseController{ $_POST['det_img'] = json_encode($_POST['det_img']); $_POST['det_name'] = json_encode($_POST['det_name']); } - $label_id = $_POST['label_id']; + if(!empty($_POST['label_id'])){ + $label_id = $_POST['label_id']; + } unset($_POST['label_id']); Db::name('goods_label') -> where('goods_id',$_POST['id']) -> delete(); - foreach ($label_id as $key => $val){ - $goods_label_data = Db::name('goods_label') -> insert(['goods_id'=>$_POST['id'],'label_id'=>$val]); + if(!empty($_POST['label_id'])){ + foreach ($label_id as $key => $val){ + $goods_label_data = Db::name('goods_label') -> insert(['goods_id'=>$_POST['id'],'label_id'=>$val]); + } } $data = Db::name('goods') -> update($_POST); if($data || $goods_label_data){ -- libgit2 0.24.0