From 7c8860106666d3a1da508b658e38852d5fd3650e Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 20 Nov 2023 15:31:39 +0000 Subject: [PATCH] Grab the API Signed-off-by: snipe --- app/Http/Controllers/Api/ConsumablesController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Http/Controllers/Api/ConsumablesController.php b/app/Http/Controllers/Api/ConsumablesController.php index b9b48328f5..1f3a347fb5 100644 --- a/app/Http/Controllers/Api/ConsumablesController.php +++ b/app/Http/Controllers/Api/ConsumablesController.php @@ -266,6 +266,14 @@ class ConsumablesController extends Controller \Log::debug('No enough remaining'); } + // Make sure there is a valid category + if (!$consumable->category){ + return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.invalid_item_category_single', ['type' => trans('general.consumable')]))); + + return redirect()->route('consumables.index')->with('error', trans('general.invalid_item_category_single', ['type' => trans('general.consumable')])); + } + + // Check if the user exists - @TODO: this should probably be handled via validation, not here?? if (!$user = User::find($request->input('assigned_to'))) { // Return error message