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

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,23 +80,25 @@ class Gallery extends Model
$fileData = isset($param['img_file']) ? $param['img_file'] : 0; $fileData = isset($param['img_file']) ? $param['img_file'] : 0;
//插入图集数据 //插入图集数据
$insertData = []; $insertData = [];
foreach ($filepathData as $key => $value) { if(is_array($filepathData)){
if (!$value) { foreach ($filepathData as $key => $value) {
continue; if (!$value) {
continue;
}
$file = [];
$file['aid'] = $insertId;
$file['title'] = $titleData[$key];
$file['desc'] = $descData[$key];
$file['link'] = $linkData[$key];
$file['sort'] = $sortData[$key];
$file['file_id'] = $fileData[$key];
$file['filepath'] = $filepathData[$key];
$file['name'] = $nameData[$key];
$file['create_time'] = time();
$insertData[] = $file;
} }
$file = []; Db::name('GalleryFile')->strict(false)->field(true)->insertAll($insertData);
$file['aid'] = $insertId;
$file['title'] = $titleData[$key];
$file['desc'] = $descData[$key];
$file['link'] = $linkData[$key];
$file['sort'] = $sortData[$key];
$file['file_id'] = $fileData[$key];
$file['filepath'] = $filepathData[$key];
$file['name'] = $nameData[$key];
$file['create_time'] = time();
$insertData[] = $file;
} }
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());