From 38a2a0c1ee2f8bb1f1b7d9e233506c7a8c68466e Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Mon, 26 Jul 2021 12:59:15 -0500 Subject: [PATCH] Add the pertinent filters in Accessories and Consumables controllers --- app/Http/Controllers/Api/AccessoriesController.php | 4 ++++ app/Http/Controllers/Api/ConsumablesController.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/Http/Controllers/Api/AccessoriesController.php b/app/Http/Controllers/Api/AccessoriesController.php index 29de7115f4..bdf290c6c8 100644 --- a/app/Http/Controllers/Api/AccessoriesController.php +++ b/app/Http/Controllers/Api/AccessoriesController.php @@ -51,6 +51,10 @@ class AccessoriesController extends Controller $accessories->where('supplier_id','=',$request->input('supplier_id')); } + if ($request->filled('location_id')) { + $accessories->where('location_id','=',$request->input('location_id')); + } + // Set the offset to the API call's offset, unless the offset is higher than the actual count of items in which // case we override with the actual count, so we should return 0 items. $offset = (($accessories) && ($request->get('offset') > $accessories->count())) ? $accessories->count() : $request->get('offset', 0); diff --git a/app/Http/Controllers/Api/ConsumablesController.php b/app/Http/Controllers/Api/ConsumablesController.php index 146311811f..44fe602159 100644 --- a/app/Http/Controllers/Api/ConsumablesController.php +++ b/app/Http/Controllers/Api/ConsumablesController.php @@ -46,6 +46,10 @@ class ConsumablesController extends Controller $consumables->where('manufacturer_id','=',$request->input('manufacturer_id')); } + if ($request->filled('location_id')) { + $consumables->where('location_id','=',$request->input('location_id')); + } + // Set the offset to the API call's offset, unless the offset is higher than the actual count of items in which // case we override with the actual count, so we should return 0 items.