diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index d0c66d4b11..2947344a50 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -55,7 +55,9 @@ class BulkAssetsController extends Controller $asset_ids = $request->input('ids'); - $assets = Asset::with('assignedTo', 'location', 'model')->find($asset_ids); + // Using the 'short-ternary' A/K/A "Elvis operator" '?:' here because ->input() might return an empty string + list($sortname,$sortdir) = explode(" ",$request->input('sort') ?: 'id ASC'); + $assets = Asset::with('assignedTo', 'location', 'model')->whereIn('id', $asset_ids)->orderBy($sortname, $sortdir)->get(); $models = $assets->unique('model_id'); $modelNames = []; diff --git a/resources/views/partials/asset-bulk-actions.blade.php b/resources/views/partials/asset-bulk-actions.blade.php index 09519501ce..d56c7dc394 100644 --- a/resources/views/partials/asset-bulk-actions.blade.php +++ b/resources/views/partials/asset-bulk-actions.blade.php @@ -6,7 +6,8 @@ 'id' => (isset($id_formname)) ? $id_formname : 'assetsBulkForm', ]) }} - + {{-- The 'id ASC' will only be used if the cookie is actually empty (like on first-use) --}} +