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