mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-12 00:21:08 +03:30
TestResultController-UpdateImages
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user