From 3ba9a3f7f1d45d7c792fb9cb59470e682a309914 Mon Sep 17 00:00:00 2001 From: Fayyazi Date: Sun, 21 Jul 2019 10:01:22 +0430 Subject: [PATCH 1/2] TestResultController-UpdateImages --- app/Http/Controllers/TestResultController.php | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/TestResultController.php b/app/Http/Controllers/TestResultController.php index 7e30ba95..0b765e62 100644 --- a/app/Http/Controllers/TestResultController.php +++ b/app/Http/Controllers/TestResultController.php @@ -265,14 +265,6 @@ class TestResultController extends Controller return $path; } - public function hasFile($key) - { - if (is_array($file = $this->file($key))) $file = head($file); - - return $file instanceof \SplFileInfo; - } - - public function update(StoreTestResultRequest $request, TestResult $TestResult) { $TestResultData = [ @@ -370,6 +362,7 @@ class TestResultController extends Controller $imageExist = []; $imagesDeleted = []; foreach ($images as $key => $image) { + $imageExist[] = '/'.$image->path; if (!in_array('/'.$image->path, $request->imgs)) { $imagesDeleted[] = $image->path; @@ -378,13 +371,13 @@ class TestResultController extends Controller } - +// strrpos($mystring, "base64") if ($request->imgs != null) { $request_imgs = array_diff($request->imgs, $imageExist); foreach ($request_imgs as $key => $img) {// - + $Image = $img; $InterventionImage = Image::make($Image); @@ -402,12 +395,14 @@ class TestResultController extends Controller //-------------------------------------------------------- } - foreach ($imagesDeleted as $key => $imageDeleted) { - $Gallery = Gallery::where('path', $imageDeleted)->findOrFail(); - if ($Gallery) { - Storage::disk('public')->delete(static::storage_path($imageDeleted)); - Uploadable::where('gallery_id', $Gallery->id)->where('uploadable_id', $TestResult->id)->where('uploadable_type', get_class($TestResult))->delete(); - $Gallery->delete(); + if (count($imagesDeleted)) { + foreach ($imagesDeleted as $key => $imageDeleted) { + $Gallery = Gallery::where('path', $imageDeleted)->findOrFail(); + if ($Gallery) { + Storage::disk('public')->delete(static::storage_path($imageDeleted)); + Uploadable::where('gallery_id', $Gallery->id)->where('uploadable_id', $TestResult->id)->where('uploadable_type', get_class($TestResult))->delete(); + $Gallery->delete(); + } } } From 2e210805fe7a872d2f3a6e4296298d1b258bb6d5 Mon Sep 17 00:00:00 2001 From: Fayyazi Date: Sun, 21 Jul 2019 10:47:35 +0430 Subject: [PATCH 2/2] CompleteUpdateImages --- app/Http/Controllers/TestResultController.php | 58 +++++-------------- public/js/vue/app.js | 8 +-- 2 files changed, 16 insertions(+), 50 deletions(-) diff --git a/app/Http/Controllers/TestResultController.php b/app/Http/Controllers/TestResultController.php index 0b765e62..34491f1c 100644 --- a/app/Http/Controllers/TestResultController.php +++ b/app/Http/Controllers/TestResultController.php @@ -326,36 +326,6 @@ class TestResultController extends Controller } /////////////////////////////////////////////////////////////////////Images $images = ''; - // if (count($TestResult->TitleImage) && $request->imgs != null) - // { - // $images = $TestResult->TitleImage; - // foreach ($images as $key => $image) { - // Storage::disk('public')->delete(static::storage_path($image->path)); - // Uploadable::where('gallery_id', $image->id)->where('uploadable_id', $TestResult->id)->where('uploadable_type', get_class($TestResult))->delete(); - // Gallery::where('id', $image->id)->delete(); - // } - // } - // - // if ($request->imgs != null) { - // foreach ($request->imgs as $key => $img) {// - // - // $Image = $img; - // $InterventionImage = Image::make($Image); - // $Mime = explode('/', $InterventionImage->mime()); - // - // $ImageName = time().$key.'.'.$Mime[1]; - // $Path = 'uploads'.'/TestResults'.'/'.$TestResult->id .'/'.$ImageName; - // - // Storage::disk('public')->makeDirectory('TestResults'.'/'.$TestResult->id); - // $InterventionImage->save(public_path($Path)); - // - // //-------------------------------------------------------- - // $GalleryObj = Gallery::create(['user_id' => auth('api')->user()->id, 'path' => $Path]); - // $Uploadable = Uploadable::create(['uploadable_id' => $TestResult->id, 'uploadable_type' => 'App\TestResult', 'gallery_id' => $GalleryObj->id, 'image_role' => 'TitleImage']); - // //-------------------------------------------------------- - // - // }// - // } if (count($TestResult->TitleImage)) { $images = $TestResult->TitleImage; @@ -371,33 +341,33 @@ class TestResultController extends Controller } -// strrpos($mystring, "base64") - if ($request->imgs != null) { $request_imgs = array_diff($request->imgs, $imageExist); foreach ($request_imgs as $key => $img) {// - $Image = $img; + if (strrpos($img, "base64") !== false) { - $InterventionImage = Image::make($Image); - $Mime = explode('/', $InterventionImage->mime()); + $Image = $img; + $InterventionImage = Image::make($Image); + $Mime = explode('/', $InterventionImage->mime()); - $ImageName = time().$key.'.'.$Mime[1]; - $Path = 'uploads'.'/TestResults'.'/'.$TestResult->id .'/'.$ImageName; + $ImageName = time().$key.'.'.$Mime[1]; + $Path = 'uploads'.'/TestResults'.'/'.$TestResult->id .'/'.$ImageName; - Storage::disk('public')->makeDirectory('TestResults'.'/'.$TestResult->id); - $InterventionImage->save(public_path($Path)); + Storage::disk('public')->makeDirectory('TestResults'.'/'.$TestResult->id); + $InterventionImage->save(public_path($Path)); - //-------------------------------------------------------- - $GalleryObj = Gallery::create(['user_id' => auth('api')->user()->id, 'path' => $Path]); - $Uploadable = Uploadable::create(['uploadable_id' => $TestResult->id, 'uploadable_type' => 'App\TestResult', 'gallery_id' => $GalleryObj->id, 'image_role' => 'TitleImage']); - //-------------------------------------------------------- + //-------------------------------------------------------- + $GalleryObj = Gallery::create(['user_id' => auth('api')->user()->id, 'path' => $Path]); + $Uploadable = Uploadable::create(['uploadable_id' => $TestResult->id, 'uploadable_type' => 'App\TestResult', 'gallery_id' => $GalleryObj->id, 'image_role' => 'TitleImage']); + //-------------------------------------------------------- + } } if (count($imagesDeleted)) { foreach ($imagesDeleted as $key => $imageDeleted) { - $Gallery = Gallery::where('path', $imageDeleted)->findOrFail(); + $Gallery = Gallery::where('path', $imageDeleted)->first(); if ($Gallery) { Storage::disk('public')->delete(static::storage_path($imageDeleted)); Uploadable::where('gallery_id', $Gallery->id)->where('uploadable_id', $TestResult->id)->where('uploadable_type', get_class($TestResult))->delete(); diff --git a/public/js/vue/app.js b/public/js/vue/app.js index 0f8ece7f..22e503db 100644 --- a/public/js/vue/app.js +++ b/public/js/vue/app.js @@ -43,11 +43,7 @@ /******/ /******/ // script path function /******/ function jsonpScriptSrc(chunkId) { -<<<<<<< HEAD -/******/ return __webpack_require__.p + "js/vue/chunks/" + ({}[chunkId]||chunkId) + "." + {"0":"cee19c932dbc149a1cc9","1":"1a2ec2568db9e0d01036","2":"567342defd47adb4346e","3":"edff967a6e6d462943a1","4":"e565c025f6fe488409e8","5":"96bde56e75e96f96d773","6":"5a5158e2d37fea70c0ad","7":"15e4bb6bc5da718a7edf","8":"c2a5317cf55cf4b30aae","9":"ec5534ce76a1d05e578f","10":"1a0d4926180438b7d7dd","11":"579917874d9306dc3854","12":"2fbc698c12dd792658de","13":"2a534d941dedd3e2828b","14":"21ee580c8e59c779a80a","15":"b930000cc9d8f16779ae","16":"adb713fe3707674161a5","17":"0cd7d9cfdd466475ba79","18":"17734129a0e2e4afdd89","19":"cfb8b7752ecb0c044cf9","20":"75f4f9028bacfd88dbae","21":"4756b5a7dd1daa6f2bb9","22":"fb95807ca2e8a3eee080","23":"0bd0fd4380524b2abc6e","24":"c24930cf7b1ec90bcb23","25":"ec97a6414b7a7daf18e2","26":"e816ed8939bdeb632640","27":"54547f942de04358714d"}[chunkId] + ".js" -======= -/******/ return __webpack_require__.p + "js/vue/chunks/" + ({}[chunkId]||chunkId) + "." + {"0":"cee19c932dbc149a1cc9","1":"5281a63adedfa1ab604f","2":"743b89b9bb2dabfa3ffe","3":"a050b1a548ee0857d2f7","4":"7c6e05813e662d286d09","5":"8d7463d42653e02550f1","6":"68a5b0bbe6eb4c67723e","7":"7b4c284293f5dd57a85d","8":"320bd23018e7d45c2399","9":"8ee8007e77852469f798","10":"9603d5be0ae5c93d2b34","11":"cf996f3dc28b604a3d3a","12":"febbfeb844354a0cdbff","13":"7441ce1b806f3f78bcbb","14":"8da587ed5e5037bb178c","15":"dc3f54190c64738d2bee","16":"b032a406fa78aefbf408","17":"aeda8d2fe82355b16c66","18":"4c39b4598f53fc5610c2","19":"44988f4163efeba55699","20":"08150bc9a6df0102406e","21":"bc068c1d2ec99a9965de","22":"9aa5bdc2ef1c37f1d6f4","23":"99044b1527f8753dde51","24":"8e2e76e3b7f37492e02f","25":"b7fe930c0eda2e6e82a5","26":"174e16952c4ab044e8bf","27":"bfdd4afc7d67ccd7ea27"}[chunkId] + ".js" ->>>>>>> eb83d7e2533274a2884a2efa593bfd66d8748f14 +/******/ return __webpack_require__.p + "js/vue/chunks/" + ({}[chunkId]||chunkId) + "." + {"0":"cee19c932dbc149a1cc9","1":"5281a63adedfa1ab604f","2":"743b89b9bb2dabfa3ffe","3":"a050b1a548ee0857d2f7","4":"7c6e05813e662d286d09","5":"8d7463d42653e02550f1","6":"68a5b0bbe6eb4c67723e","7":"7b4c284293f5dd57a85d","8":"320bd23018e7d45c2399","9":"8ee8007e77852469f798","10":"9603d5be0ae5c93d2b34","11":"cf996f3dc28b604a3d3a","12":"febbfeb844354a0cdbff","13":"7441ce1b806f3f78bcbb","14":"8da587ed5e5037bb178c","15":"dc3f54190c64738d2bee","16":"b032a406fa78aefbf408","17":"aeda8d2fe82355b16c66","18":"4c39b4598f53fc5610c2","19":"44988f4163efeba55699","20":"08150bc9a6df0102406e","21":"bc068c1d2ec99a9965de","22":"9aa5bdc2ef1c37f1d6f4","23":"99044b1527f8753dde51","24":"8e2e76e3b7f37492e02f","25":"99927094d1dc83174482","26":"174e16952c4ab044e8bf","27":"bfdd4afc7d67ccd7ea27"}[chunkId] + ".js" /******/ } /******/ /******/ // The require function @@ -67516,7 +67512,7 @@ module.exports = webpackAsyncContext; /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(/*! D:\Atom\Git\CSSD\resources\js\vue\main.js */"./resources/js/vue/main.js"); +module.exports = __webpack_require__(/*! D:\FYZ\CSSD\resources\js\vue\main.js */"./resources/js/vue/main.js"); /***/ })