| xqd
@@ -152,6 +152,7 @@ class InfoController extends Controller
|
|
|
$arr[] = $pic['pic'];
|
|
|
}
|
|
|
$data->imgs = $arr;
|
|
|
+// dd($data);
|
|
|
$data['sign'] = explode(',',$data['sign']);
|
|
|
$signs = BaseSettingsModel::where('category','sign')->orderBy('id')->get();
|
|
|
return view('admin.dream.info.edit',compact('data','signs'));
|
| xqd
@@ -193,35 +194,50 @@ class InfoController extends Controller
|
|
|
$data['score'] = (log($care_num) + ($a/$t) + $b)*100000000 ;
|
|
|
}
|
|
|
$pics = (array) request('pic');
|
|
|
- if (empty($pics)) {
|
|
|
- $url[] = array('url'=>U( 'Dream/Info/index'),'title'=>'返回列表');
|
|
|
- return $this->showWarning('请添加图片',$url);
|
|
|
+ if (request("file")) {
|
|
|
+ $file = request("file");
|
|
|
+ $fileSize = $file->getSize();
|
|
|
+ $size = 200 * 1024 * 1024;
|
|
|
+ if ($fileSize > $size) {
|
|
|
+ return back()->with('error','请上传小于200 MB的文件!');
|
|
|
+ }
|
|
|
+ $mimeType = [
|
|
|
+ 'video/mp4',
|
|
|
+ ];
|
|
|
+ $fileMimeType = $file->getMimeType();
|
|
|
+ if (!empty($mimeType) && !in_array($fileMimeType, $mimeType)) {
|
|
|
+ return back()->with('error','File type allow MP4!');
|
|
|
+ }
|
|
|
+ if (!$file = VideoUpload::mvFile('file')) return back()->with('error','上传失败');
|
|
|
+ $data["video"] = $file;
|
|
|
}
|
|
|
- $old_data_pics = $this->repository->find(request('id'))->imgs->toArray();
|
|
|
- $old_pics = array_column($old_data_pics,'pic');
|
|
|
- $a = array_diff($pics['url'],$old_pics);
|
|
|
- $b = array_diff($old_pics,$pics['url']);
|
|
|
- if (!empty($a) || !empty($b)) { //有图片变化执行
|
|
|
- // 删除以前图片 重新插入
|
|
|
- if (!empty($b)) {
|
|
|
- foreach ($b as $old_pic){
|
|
|
- if (is_file('.'.str_replace(getenv('APP_URL'),'',$old_pic))) {
|
|
|
- unlink('.'.str_replace(getenv('APP_URL'),'',$old_pic));
|
|
|
+ if (!empty($pics)) {
|
|
|
+ $old_data_pics = $this->repository->find(request('id'))->imgs->toArray();
|
|
|
+ $old_pics = array_column($old_data_pics,'pic');
|
|
|
+ $a = array_diff($pics['url'],$old_pics);
|
|
|
+ $b = array_diff($old_pics,$pics['url']);
|
|
|
+ if (!empty($a) || !empty($b)) { //有图片变化执行
|
|
|
+ // 删除以前图片 重新插入
|
|
|
+ if (!empty($b)) {
|
|
|
+ foreach ($b as $old_pic){
|
|
|
+ if (is_file('.'.str_replace(getenv('APP_URL'),'',$old_pic))) {
|
|
|
+ unlink('.'.str_replace(getenv('APP_URL'),'',$old_pic));
|
|
|
+ }
|
|
|
+ BaseAttachmentModel::where('url',$old_pic)->delete();
|
|
|
+ DreamImages::where('pic',$old_pic)->delete();
|
|
|
}
|
|
|
- BaseAttachmentModel::where('url',$old_pic)->delete();
|
|
|
- DreamImages::where('pic',$old_pic)->delete();
|
|
|
}
|
|
|
+ $arr = []; //插入新的图片
|
|
|
+ foreach ($a as $pic) {
|
|
|
+ $arr[] = [
|
|
|
+ 'pic'=>getenv('APP_URL').$pic,
|
|
|
+ 'dream_id'=>request('id'),
|
|
|
+ 'created_at'=>date('Y-m-d H:i:s'),
|
|
|
+ 'updated_at'=>date('Y-m-d H:i:s'),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ DreamImages::insert($arr);
|
|
|
}
|
|
|
- $arr = []; //插入新的图片
|
|
|
- foreach ($a as $pic) {
|
|
|
- $arr[] = [
|
|
|
- 'pic'=>getenv('APP_URL').$pic,
|
|
|
- 'dream_id'=>request('id'),
|
|
|
- 'created_at'=>date('Y-m-d H:i:s'),
|
|
|
- 'updated_at'=>date('Y-m-d H:i:s'),
|
|
|
- ];
|
|
|
- }
|
|
|
- DreamImages::insert($arr);
|
|
|
}
|
|
|
$ok = $this->repository->update(request('id'),$data);
|
|
|
if ($data['status'] == 1) { //审核通过
|
| xqd
@@ -233,7 +249,7 @@ class InfoController extends Controller
|
|
|
SystemInfoModel::create($info);
|
|
|
|
|
|
// 长连接
|
|
|
- $this->jPush($message,'',$data['user_id']);
|
|
|
+// $this->jPush($message,'',$data['user_id']);
|
|
|
}
|
|
|
if($ok) {
|
|
|
$url[] = array('url'=>U( 'Dream/Info/index'),'title'=>'返回列表');
|