From f270f307289c8fb59efdb140467c407288e70c1b Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 7 Mar 2024 12:30:08 -0800 Subject: [PATCH 1/2] Redirect if no assets are returned from query --- app/Http/Controllers/Assets/BulkAssetsController.php | 6 ++++++ resources/lang/en-US/admin/hardware/message.php | 1 + 2 files changed, 7 insertions(+) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 51892e4259..561e13b200 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -14,6 +14,7 @@ use App\View\Label; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Session; use App\Http\Requests\AssetCheckoutRequest; use App\Models\CustomField; @@ -95,6 +96,11 @@ class BulkAssetsController extends Controller $assets = $assets->get(); + if ($assets->isEmpty()) { + Log::debug('No assets were found for the provided IDs', ['ids' => $asset_ids]); + return redirect()->back()->with('error', trans('admin/hardware/message.update.assets_do_not_exist_or_are_invalid')); + } + $models = $assets->unique('model_id'); $modelNames = []; foreach($models as $model) { diff --git a/resources/lang/en-US/admin/hardware/message.php b/resources/lang/en-US/admin/hardware/message.php index 056692998e..bf050ef974 100644 --- a/resources/lang/en-US/admin/hardware/message.php +++ b/resources/lang/en-US/admin/hardware/message.php @@ -19,6 +19,7 @@ return [ 'success' => 'Asset updated successfully.', 'nothing_updated' => 'No fields were selected, so nothing was updated.', 'no_assets_selected' => 'No assets were selected, so nothing was updated.', + 'assets_do_not_exist_or_are_invalid' => 'Selected assets cannot be updated.', ], 'restore' => [ From d83974e07fce859717abf05e7e2a10bed1a256bc Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 7 Mar 2024 13:03:10 -0800 Subject: [PATCH 2/2] old engine works as intended --- app/View/Label.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/View/Label.php b/app/View/Label.php index 21c839fa11..a3d4ac5798 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -41,7 +41,7 @@ class Label implements View $template = LabelModel::find($settings->label2_template); // If disabled, pass to legacy view - if ((!$settings->label2_enable) && (!$template)) { + if ((!$settings->label2_enable)) { return view('hardware/labels') ->with('assets', $assets) ->with('settings', $settings)