| xqd
@@ -8,6 +8,7 @@
|
|
|
*/
|
|
|
namespace App\Http\Controllers\Admin\Dream;
|
|
|
use App\Http\Controllers\Admin\Controller;
|
|
|
+use App\Models\Attachment;
|
|
|
use App\Models\BaseAttachmentModel;
|
|
|
use App\Models\BaseSettingsModel;
|
|
|
use App\Models\DreamImages;
|
| xqd
@@ -113,8 +114,8 @@ class InfoController extends Controller
|
|
|
$data['sign'] = join(',',$data['sign']);
|
|
|
}
|
|
|
$pics = (array) request('pic');
|
|
|
- if (request("file")) {
|
|
|
- $file = request("file");
|
|
|
+ if (!empty(request("video"))) {
|
|
|
+ $file = request("video");
|
|
|
$fileSize = $file->getSize();
|
|
|
$size = 200 * 1024 * 1024;
|
|
|
if ($fileSize > $size) {
|
| xqd
@@ -146,7 +147,7 @@ class InfoController extends Controller
|
|
|
if (!empty($pics)) {
|
|
|
foreach ($pics['url'] as $pic) {
|
|
|
$arr[] = [
|
|
|
- 'pic'=>getenv('APP_URL').$pic,
|
|
|
+ 'pic'=>$pic,
|
|
|
'dream_id'=>$id,
|
|
|
'created_at'=>date("Y-m-d H:i:s"),
|
|
|
'updated_at'=>date("Y-m-d H:i:s"),
|
| xqd
@@ -187,6 +188,7 @@ class InfoController extends Controller
|
|
|
$data->imgs = $arr;
|
|
|
$data['sign'] = explode(',',$data['sign']);
|
|
|
$signs = BaseSettingsModel::where('category','sign')->orderBy('id')->get();
|
|
|
+// dd($data);
|
|
|
return view('admin.dream.info.edit',compact('data','signs'));
|
|
|
}
|
|
|
|
| xqd
@@ -229,7 +231,7 @@ class InfoController extends Controller
|
|
|
$data['score'] = (log($care_num,$x) + ($a/$t) + $b)*100000000000000 ;
|
|
|
}
|
|
|
$pics = (array) request('pic');
|
|
|
- if (request("file")) {
|
|
|
+ /* if (request("file")) {
|
|
|
$file = request("file");
|
|
|
$fileSize = $file->getSize();
|
|
|
$size = 200 * 1024 * 1024;
|
| xqd
@@ -253,10 +255,22 @@ class InfoController extends Controller
|
|
|
}
|
|
|
$dream->video = '';
|
|
|
$dream->save();
|
|
|
- }
|
|
|
+ }*/
|
|
|
if (!empty($pics)) {
|
|
|
// 图片不为空
|
|
|
$old_data_pics = $this->repository->find(request('id'))->imgs->toArray();
|
|
|
+ $old_pics = array_column($old_data_pics,'pic');
|
|
|
+ //操作成功,删除原来的图片
|
|
|
+ foreach ($old_pics as $pic) {
|
|
|
+ if (!in_array($pic, $pics['url'])) {
|
|
|
+ $md5 = $this->getarea($pic);
|
|
|
+ $attache = new \App\Services\Base\Attachment();
|
|
|
+ $attache->deleteAttachment($md5);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
$old_pics = array_column($old_data_pics,'pic');
|
|
|
$a = array_diff($pics['url'],$old_pics);
|
|
|
$b = array_diff($old_pics,$pics['url']);
|
| xqd
@@ -371,4 +385,14 @@ class InfoController extends Controller
|
|
|
$list = $query->with('user')->where('dream_id',$dream_id)->paginate();
|
|
|
return view('admin.dream.support_dream.index',compact('list'));
|
|
|
}
|
|
|
+
|
|
|
+// 获取视频图片后缀码
|
|
|
+ public function getarea($str)
|
|
|
+ {
|
|
|
+ $start = strripos($str, '/');
|
|
|
+ $first = substr($str, $start + 1);
|
|
|
+ $end = strripos($first, '.');
|
|
|
+ $last = substr($first, 0, $end);
|
|
|
+ return $last;
|
|
|
+ }
|
|
|
}
|