From 7a424649c83f68e30174d37ac61444ce89b94b38 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Wed, 7 Jul 2021 09:24:24 +0300 Subject: [PATCH] convert image_source field This reverts commit b2d3ba74102f76428eefbcf8a01f9329bff4dfc7. --- app/Http/Controllers/Api/AssetsController.php | 39 ------------------- app/Http/Requests/ImageUploadRequest.php | 5 +++ 2 files changed, 5 insertions(+), 39 deletions(-) diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index dbd092a525..d3e881038f 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -459,22 +459,6 @@ class AssetsController extends Controller $asset->rtd_location_id = $request->get('rtd_location_id', null); $asset->location_id = $request->get('rtd_location_id', null); - if ($request->has('image_source') && $request->input('image_source') != "") { - $saved_image_path = Helper::processUploadedImage( - $request->input('image_source'), 'uploads/assets/' - ); - - if (!$saved_image_path) { - return response()->json(Helper::formatStandardApiResponse( - 'error', - null, - trans('admin/hardware/message.create.error') - ), 200); - } - - $asset->image = $saved_image_path; - } - $asset = $request->handleImages($asset); // Update custom fields in the database. @@ -561,31 +545,8 @@ class AssetsController extends Controller ($request->filled('company_id')) ? $asset->company_id = Company::getIdForCurrentUser($request->get('company_id')) : ''; -($request->filled('rtd_location_id')) ? - $asset->location_id = $request->get('rtd_location_id') : null; - - - if ($request->filled('image_source')) { - if ($request->input('image_source') == "") { ($request->filled('rtd_location_id')) ? $asset->location_id = $request->get('rtd_location_id') : null; - $asset->image = null; - } else { - $saved_image_path = Helper::processUploadedImage( - $request->input('image_source'), 'uploads/assets/' - ); - - if (!$saved_image_path) { - return response()->json(Helper::formatStandardApiResponse( - 'error', - null, - trans('admin/hardware/message.update.error') - ), 200); - } - - $asset->image = $saved_image_path; - } - } $asset = $request->handleImages($asset); diff --git a/app/Http/Requests/ImageUploadRequest.php b/app/Http/Requests/ImageUploadRequest.php index 6ad002f9bb..0ed4561ae6 100644 --- a/app/Http/Requests/ImageUploadRequest.php +++ b/app/Http/Requests/ImageUploadRequest.php @@ -47,8 +47,13 @@ class ImageUploadRequest extends Request */ protected function base64FileKeys(): array { + /** + * image_source is here just legacy reasons. Api\AssetController + * had it once to allow encoded image uploads. + */ return [ 'image' => 'auto', + 'image_source' => 'auto' ]; }