From 5d999d2572253709fa89f2fc135e653e0f914a5c Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Wed, 14 Jul 2021 08:00:02 +0300 Subject: [PATCH] legacy image_source support for store --- app/Http/Controllers/Api/AssetsController.php | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 7c3cc3fb09..0cfef5eb99 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -416,26 +416,34 @@ class AssetsController extends Controller $asset = new Asset(); $asset->model()->associate(AssetModel::find((int) $request->get('model_id'))); - $asset->name = $request->get('name'); - $asset->serial = $request->get('serial'); - $asset->company_id = Company::getIdForCurrentUser($request->get('company_id')); - $asset->model_id = $request->get('model_id'); - $asset->order_number = $request->get('order_number'); - $asset->notes = $request->get('notes'); - $asset->asset_tag = $request->get('asset_tag', Asset::autoincrement_asset()); - $asset->user_id = Auth::id(); - $asset->archived = '0'; - $asset->physical = '1'; - $asset->depreciate = '0'; - $asset->status_id = $request->get('status_id', 0); - $asset->warranty_months = $request->get('warranty_months', null); - $asset->purchase_cost = Helper::ParseFloat($request->get('purchase_cost')); - $asset->purchase_date = $request->get('purchase_date', null); - $asset->assigned_to = $request->get('assigned_to', null); - $asset->supplier_id = $request->get('supplier_id', 0); - $asset->requestable = $request->get('requestable', 0); - $asset->rtd_location_id = $request->get('rtd_location_id', null); - $asset->location_id = $request->get('rtd_location_id', null); + $asset->name = $request->get('name'); + $asset->serial = $request->get('serial'); + $asset->company_id = Company::getIdForCurrentUser($request->get('company_id')); + $asset->model_id = $request->get('model_id'); + $asset->order_number = $request->get('order_number'); + $asset->notes = $request->get('notes'); + $asset->asset_tag = $request->get('asset_tag', Asset::autoincrement_asset()); + $asset->user_id = Auth::id(); + $asset->archived = '0'; + $asset->physical = '1'; + $asset->depreciate = '0'; + $asset->status_id = $request->get('status_id', 0); + $asset->warranty_months = $request->get('warranty_months', null); + $asset->purchase_cost = Helper::ParseFloat($request->get('purchase_cost')); + $asset->purchase_date = $request->get('purchase_date', null); + $asset->assigned_to = $request->get('assigned_to', null); + $asset->supplier_id = $request->get('supplier_id', 0); + $asset->requestable = $request->get('requestable', 0); + $asset->rtd_location_id = $request->get('rtd_location_id', null); + $asset->location_id = $request->get('rtd_location_id', null); + + /** + * this is here just legacy reasons. Api\AssetController + * used image_source once to allow encoded image uploads. + */ + if ($request->has('image_source')) { + $request->offsetSet('image', $request->offsetGet('image_source')); + } $asset = $request->handleImages($asset);