Merge pull request #14430 from snipe/bug/sc-25066/fixed_requestable_search

Move requestable scope below sorting, etc
This commit is contained in:
snipe 2024-03-14 13:25:44 +00:00 committed by GitHub
commit 4e835e1772
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1062,8 +1062,7 @@ class AssetsController extends Controller
$assets = Asset::select('assets.*')
->with('location', 'assetstatus', 'assetlog', 'company','assignedTo',
'model.category', 'model.manufacturer', 'model.fieldset', 'supplier', 'requests')
->requestableAssets();
'model.category', 'model.manufacturer', 'model.fieldset', 'supplier', 'requests');
@ -1071,7 +1070,7 @@ class AssetsController extends Controller
if ($request->filled('search')) {
$assets->TextSearch($request->input('search'));
}
// Search custom fields by column name
foreach ($all_custom_fields as $field) {
if ($request->filled($field->db_column_name())) {
@ -1101,6 +1100,7 @@ class AssetsController extends Controller
break;
}
$assets->requestableAssets();
// Make sure the offset and limit are actually integers and do not exceed system limits
$offset = ($request->input('offset') > $assets->count()) ? $assets->count() : app('api_offset_value');