A free open source IT asset/license management system
fix tests
Godfrey Meaacf29d57ec
diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.phpindex d38350f5b2..6ad5ae20d2 100644--- a/app/Http/Controllers/Assets/BulkAssetsController.php+++ b/app/Http/Controllers/Assets/BulkAssetsController.php@@ -529,22 +529,27 @@ class BulkAssetsController extends Controllerif ($request->session()->has('bulk_back_url')) {$bulk_back_url = $request->session()->pull('bulk_back_url');}- $assetIds = $request->get('ids');+ $assetIds = $request->get('ids') ?? [];++ if(empty($assetIds)) {+ return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.delete.nothing_updated'));+ }+$assignedAssets = Asset::whereIn('id', $assetIds)->whereNotNull('assigned_to')->get();if($assignedAssets->isNotEmpty()) {//if assets are checked out, return a list of asset tags that would need to be checked in first.$assetTags = $assignedAssets->pluck('asset_tag')->implode(', ');- return redirect()->route('hardware.index')->with('error', trans_choice('admin/hardware/message.delete.assigned_to_error', $assignedAssets->count(), ['asset_tag' => $assetTags] ));+ return redirect()->route($bulk_back_url)->with('error', trans_choice('admin/hardware/message.delete.assigned_to_error', $assignedAssets->count(), ['asset_tag' => $assetTags] ));}- if($assetIds) {- Asset::wherein('id', $assetIds)->delete();- return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.delete.success'));- }+ foreach (Asset::wherein('id', $assetIds)->get() as $asset) {+ $asset->delete();+ }++ return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.delete.success'));// no values given, nothing to update- return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.delete.nothing_updated'));}/**