Skip to content

A free open source IT asset/license management system

Fixed #6676 - consumables API not respecting category id

snipe5c9b1ed43af7
diff --git a/app/Http/Controllers/Api/ConsumablesController.php b/app/Http/Controllers/Api/ConsumablesController.php
index faf485f882..d609c35a9c 100644
--- a/app/Http/Controllers/Api/ConsumablesController.php
+++ b/app/Http/Controllers/Api/ConsumablesController.php
@@ -35,12 +35,16 @@ class ConsumablesController extends Controller
$consumables->where('company_id','=',$request->input('company_id'));
}
+ if ($request->has('category_id')) {
+ $consumables->where('category_id','=',$request->input('category_id'));
+ }
+
if ($request->has('manufacturer_id')) {
$consumables->where('manufacturer_id','=',$request->input('manufacturer_id'));
}
- $offset = request('offset', 0);
+ $offset = (($consumables) && (request('offset') > $consumables->count())) ? 0 : request('offset', 0);
$limit = request('limit', 50);
$allowed_columns = ['id','name','order_number','min_amt','purchase_date','purchase_cost','company','category','model_number', 'item_no', 'manufacturer','location','qty','image'];
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';