|
@@ -216,58 +216,62 @@ JS
|
|
|
$form->disableViewButton();
|
|
|
$form->disableViewCheck();
|
|
|
$form->saving(function (Form $form) use ($thisObj) {
|
|
|
- //处理video
|
|
|
- $videos = $form->input('video');
|
|
|
- if ($videos) {
|
|
|
- foreach ($videos as $key => $value) {
|
|
|
- if (empty($value['cover']) && $value['_remove_'] != 1) {
|
|
|
- //自动生成封面
|
|
|
- $result = $thisObj->autoGenerateCover($value['video_src']);
|
|
|
- if ($result['status']) {
|
|
|
- $videos[$key]['cover'] = $result['path'];
|
|
|
- } else {
|
|
|
- return $form->response()->error($result['msg']);
|
|
|
+ if ($form->input('title')) {
|
|
|
+ //处理video
|
|
|
+ $videos = $form->input('video');
|
|
|
+ if ($videos) {
|
|
|
+ foreach ($videos as $key => $value) {
|
|
|
+ if (empty($value['cover']) && $value['_remove_'] != 1) {
|
|
|
+ //自动生成封面
|
|
|
+ $result = $thisObj->autoGenerateCover($value['video_src']);
|
|
|
+ if ($result['status']) {
|
|
|
+ $videos[$key]['cover'] = $result['path'];
|
|
|
+ } else {
|
|
|
+ return $form->response()->error($result['msg']);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ $videos = [];
|
|
|
+ }
|
|
|
+ $form->input('video', $videos);
|
|
|
+ //处理pdf
|
|
|
+ $pdfs = $form->input('pdf');
|
|
|
+ $pdfs = empty($pdfs) ? [] : $pdfs;
|
|
|
+ $form->input('pdf', $pdfs);
|
|
|
+ //记录日志
|
|
|
+ if (!$form->isCreating()) {
|
|
|
+ $id = $form->getKey();
|
|
|
+ $cacheKey = 'album_log_'.$id;
|
|
|
+ Cache::add($cacheKey, json_encode($form->model()->toArray()), 3600);
|
|
|
}
|
|
|
- } else {
|
|
|
- $videos = [];
|
|
|
- }
|
|
|
- $form->input('video', $videos);
|
|
|
- //处理pdf
|
|
|
- $pdfs = $form->input('pdf');
|
|
|
- $pdfs = empty($pdfs) ? [] : $pdfs;
|
|
|
- $form->input('pdf', $pdfs);
|
|
|
- //记录日志
|
|
|
- if (!$form->isCreating()) {
|
|
|
- $id = $form->getKey();
|
|
|
- $cacheKey = 'album_log_'.$id;
|
|
|
- Cache::add($cacheKey, json_encode($form->model()->toArray()), 3600);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$form->saved(function (Form $form) {
|
|
|
- $id = $form->getKey();
|
|
|
- if (empty($form->input('model')) == false) {
|
|
|
-
|
|
|
- $action = $form->isCreating() ? 'add' : 'edit';
|
|
|
- if ($action == 'add') {
|
|
|
- $oldData = "[]";
|
|
|
- } else {
|
|
|
- $oldData = Cache::get('album_log_'. $id);
|
|
|
- Cache::forget('album_log_'. $id);
|
|
|
+ if ($form->input('title')) {
|
|
|
+ $id = $form->getKey();
|
|
|
+ if (empty($form->input('model')) == false) {
|
|
|
+
|
|
|
+ $action = $form->isCreating() ? 'add' : 'edit';
|
|
|
+ if ($action == 'add') {
|
|
|
+ $oldData = "[]";
|
|
|
+ } else {
|
|
|
+ $oldData = Cache::get('album_log_'. $id);
|
|
|
+ Cache::forget('album_log_'. $id);
|
|
|
+ }
|
|
|
+ SiteAlbumLog::log($action, $id,$form->input('model'),$oldData);
|
|
|
}
|
|
|
- SiteAlbumLog::log($action, $id,$form->input('model'),$oldData);
|
|
|
- }
|
|
|
- //更新site_preview_video表
|
|
|
- $video = $form->input('video');
|
|
|
- $data = [];
|
|
|
- foreach ($video as $value) {
|
|
|
- if ($value['_remove_'] != 1){
|
|
|
- $data[] = ['cover'=>$value['cover'],'video_title'=>$value['video_title'],'video_en_title' => $value['video_en_title'],'video_src'=>$value['video_src']];
|
|
|
+ //更新site_preview_video表
|
|
|
+ $video = $form->input('video');
|
|
|
+ $data = [];
|
|
|
+ foreach ($video as $value) {
|
|
|
+ if ($value['_remove_'] != 1){
|
|
|
+ $data[] = ['cover'=>$value['cover'],'video_title'=>$value['video_title'],'video_en_title' => $value['video_en_title'],'video_src'=>$value['video_src']];
|
|
|
+ }
|
|
|
}
|
|
|
+ SitePreviewVideo::updatePreviewVideo($id,$data);
|
|
|
}
|
|
|
- SitePreviewVideo::updatePreviewVideo($id,$data);
|
|
|
});
|
|
|
|
|
|
$form->tab(admin_trans_label('basic_info'), function (Form $form) {
|