From 2fe7fcecdb24dd472b19f3a372b9f20547bf0387 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 13 Apr 2023 11:13:45 -0700 Subject: [PATCH] Added case switch for sorting on suppliers Signed-off-by: snipe --- app/Http/Controllers/Api/ComponentsController.php | 9 ++++++++- app/Http/Controllers/Api/ConsumablesController.php | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/ComponentsController.php b/app/Http/Controllers/Api/ComponentsController.php index bf281d6b2b..2c1d8e75c0 100644 --- a/app/Http/Controllers/Api/ComponentsController.php +++ b/app/Http/Controllers/Api/ComponentsController.php @@ -46,7 +46,7 @@ class ComponentsController extends Controller $components = Company::scopeCompanyables(Component::select('components.*') - ->with('company', 'location', 'category', 'assets')); + ->with('company', 'location', 'category', 'assets', 'supplier')); if ($request->filled('search')) { $components = $components->TextSearch($request->input('search')); @@ -64,6 +64,10 @@ class ComponentsController extends Controller $components->where('category_id', '=', $request->input('category_id')); } + if ($request->filled('supplier_id')) { + $components->where('supplier_id', '=', $request->input('supplier_id')); + } + if ($request->filled('location_id')) { $components->where('location_id', '=', $request->input('location_id')); } @@ -94,6 +98,9 @@ class ComponentsController extends Controller case 'company': $components = $components->OrderCompany($order); break; + case 'supplier': + $components = $components->OrderSupplier($order); + break; default: $components = $components->orderBy($column_sort, $order); break; diff --git a/app/Http/Controllers/Api/ConsumablesController.php b/app/Http/Controllers/Api/ConsumablesController.php index e9a069c379..25c411963b 100644 --- a/app/Http/Controllers/Api/ConsumablesController.php +++ b/app/Http/Controllers/Api/ConsumablesController.php @@ -75,6 +75,10 @@ class ConsumablesController extends Controller $consumables->where('manufacturer_id', '=', $request->input('manufacturer_id')); } + if ($request->filled('supplier_id')) { + $consumables->where('supplier_id', '=', $request->input('supplier_id')); + } + if ($request->filled('location_id')) { $consumables->where('location_id','=',$request->input('location_id')); } @@ -111,6 +115,9 @@ class ConsumablesController extends Controller case 'company': $consumables = $consumables->OrderCompany($order); break; + case 'supplier': + $components = $consumables->OrderSupplier($order); + break; default: $consumables = $consumables->orderBy($column_sort, $order); break;