diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index bd64ae8c98..16cef00d4d 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -137,9 +137,6 @@ class AssetsController extends Controller } - - $request->filled('order_number') ? $assets = $assets->where('assets.order_number', '=', e($request->get('order_number'))) : ''; - // Make sure the offset and limit are actually integers and do not exceed system limits $offset = ($request->input('offset') > $assets->count()) ? $assets->count() : abs($request->input('offset')); $limit = app('api_limit_value'); @@ -303,6 +300,10 @@ class AssetsController extends Controller $assets->where('assets.byod', '=', $request->input('byod')); } + if ($request->filled('order_number')) { + $assets->where('assets.order_number', '=', $request->get('order_number')); + } + // This is kinda gross, but we need to do this because the Bootstrap Tables // API passes custom field ordering as custom_fields.fieldname, and we have to strip // that out to let the default sorter below order them correctly on the assets table.