diff --git a/app/Actions/Assets/StoreAssetAction.php b/app/Actions/Assets/StoreAssetAction.php index b1dcb573d3..fa1b56eabd 100644 --- a/app/Actions/Assets/StoreAssetAction.php +++ b/app/Actions/Assets/StoreAssetAction.php @@ -176,7 +176,7 @@ class StoreAssetAction } return $asset; } else { - return $asset->getErrors(); + dd($asset->getErrors()); //need to figure out how to return errors from watson validating... } } } \ No newline at end of file diff --git a/app/Actions/Assets/UpdateAssetAction.php b/app/Actions/Assets/UpdateAssetAction.php index a6651ba856..117c8f0ae6 100644 --- a/app/Actions/Assets/UpdateAssetAction.php +++ b/app/Actions/Assets/UpdateAssetAction.php @@ -8,5 +8,4 @@ class UpdateAssetAction { // stuff } - } \ No newline at end of file diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 1dc5034e9b..c650d9f699 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -117,7 +117,7 @@ class AssetsController extends Controller model_id: $request->validated('model_id'), status_id: $request->validated('status_id'), name: $request->validated('name'), - serial: $serials[$key], + serial: $request->has('serials') ? $serials[$key] : null, company_id: $request->validated('company_id'), asset_tag: $asset_tag, order_number: $request->validated('order_number'), @@ -138,7 +138,7 @@ class AssetsController extends Controller assigned_asset: $request->validated('assigned_asset'), assigned_location: $request->validated('assigned_location'), custom_fields: $custom_fields, - request: $request, //this is just for the handleImages method... + request: $request, //this is just for the handleImages method... would love to figure out a different way of doing this last_audit_date: $request->validated('last_audit_date'), ); } @@ -149,7 +149,9 @@ class AssetsController extends Controller } catch (CheckoutNotAllowed $e) { return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.create.error')); } catch (\Exception $e) { - return redirect()->back()->with('error', trans('admin/hardware/message.create.error')); + report($e); + dd($e); + return redirect()->back()->with('error', 'something bad'); } } diff --git a/app/Http/Requests/Assets/StoreAssetRequest.php b/app/Http/Requests/Assets/StoreAssetRequest.php index 574216afdf..c3db8108a5 100644 --- a/app/Http/Requests/Assets/StoreAssetRequest.php +++ b/app/Http/Requests/Assets/StoreAssetRequest.php @@ -37,8 +37,10 @@ class StoreAssetRequest extends ImageUploadRequest $this->parseLastAuditDate(); + $asset_tag = $this->parseAssetTag(); + $this->merge([ - 'asset_tag' => $this->asset_tag ?? Asset::autoincrement_asset(), + 'asset_tag' => $asset_tag, 'company_id' => $idForCurrentUser, 'assigned_to' => $assigned_to ?? null, ]); @@ -61,7 +63,6 @@ class StoreAssetRequest extends ImageUploadRequest // converted to a float via setPurchaseCostAttribute). $modelRules = $this->removeNumericRulesFromPurchaseCost($modelRules); } - return array_merge( $modelRules, ['status_id' => [new AssetCannotBeCheckedOutToNondeployableStatus()]], @@ -101,4 +102,14 @@ class StoreAssetRequest extends ImageUploadRequest return $rules; } + + private function parseAssetTag(): mixed + { + // this is for a gui request to make the request pass validation + // this just checks the first asset tag from the gui, watson should pick up if any of the rest of them fail + if ($this->has('asset_tags') && !$this->expectsJson()) { + return $this->input('asset_tags')[1]; + } + return $this->asset_tag ?? Asset::autoincrement_asset(); + } }