From 4e8ae8a162403478d749a5f607daabf809161285 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Thu, 13 Jan 2022 16:32:40 -0800 Subject: [PATCH 1/2] Fix extraneous wildcard query in requestable asset search --- app/Http/Controllers/Api/AssetsController.php | 4 +++- app/Http/Controllers/ViewAssetsController.php | 4 ++-- resources/views/account/requestable-assets.blade.php | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 614c61d7ba..dd99668eac 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -942,7 +942,9 @@ class AssetsController extends Controller $offset = request('offset', 0); $limit = $request->input('limit', 50); $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; - $assets->TextSearch($request->input('search')); + if ($request->filled('search')) { + $assets->TextSearch($request->input('search')); + } switch ($request->input('sort')) { case 'model': diff --git a/app/Http/Controllers/ViewAssetsController.php b/app/Http/Controllers/ViewAssetsController.php index e6da196038..00245f0b2c 100755 --- a/app/Http/Controllers/ViewAssetsController.php +++ b/app/Http/Controllers/ViewAssetsController.php @@ -57,10 +57,10 @@ class ViewAssetsController extends Controller */ public function getRequestableIndex() { - $assets = Asset::with('model', 'defaultLoc', 'location', 'assignedTo', 'requests')->Hardware()->RequestableAssets(); + $asset_count = Asset::with('model', 'defaultLoc', 'location', 'assignedTo', 'requests')->Hardware()->RequestableAssets()->count(); $models = AssetModel::with('category', 'requests', 'assets')->RequestableModels()->get(); - return view('account/requestable-assets', compact('assets', 'models')); + return view('account/requestable-assets', compact('asset_count', 'models')); } public function getRequestItem(Request $request, $itemType, $itemId = null) diff --git a/resources/views/account/requestable-assets.blade.php b/resources/views/account/requestable-assets.blade.php index b17fd98e82..98f199a8b7 100644 --- a/resources/views/account/requestable-assets.blade.php +++ b/resources/views/account/requestable-assets.blade.php @@ -20,7 +20,7 @@