图集模块为上传图集无法新增问题修复

This commit is contained in:
hdm 2022-09-19 13:01:00 +08:00
parent fa8a05ce5d
commit 2a7f0a3fb6
2 changed files with 18 additions and 16 deletions

View File

@ -64,7 +64,7 @@ class Gallery extends BaseController
// 验证失败 输出错误信息 // 验证失败 输出错误信息
return to_assign(1, $e->getError()); return to_assign(1, $e->getError());
} }
$param['admin_id'] = $tis->uid; $param['admin_id'] = $this->uid;
$this->model->addGallery($param); $this->model->addGallery($param);
}else{ }else{
return view(); return view();

View File

@ -80,6 +80,7 @@ class Gallery extends Model
$fileData = isset($param['img_file']) ? $param['img_file'] : 0; $fileData = isset($param['img_file']) ? $param['img_file'] : 0;
//插入图集数据 //插入图集数据
$insertData = []; $insertData = [];
if(is_array($filepathData)){
foreach ($filepathData as $key => $value) { foreach ($filepathData as $key => $value) {
if (!$value) { if (!$value) {
continue; continue;
@ -97,6 +98,7 @@ class Gallery extends Model
$insertData[] = $file; $insertData[] = $file;
} }
Db::name('GalleryFile')->strict(false)->field(true)->insertAll($insertData); Db::name('GalleryFile')->strict(false)->field(true)->insertAll($insertData);
}
add_log('add', $insertId, $param); add_log('add', $insertId, $param);
} catch(\Exception $e) { } catch(\Exception $e) {
return to_assign(1, '操作失败,原因:'.$e->getMessage()); return to_assign(1, '操作失败,原因:'.$e->getMessage());