diff --git a/app/Http/Controllers/Api/AssetModelsController.php b/app/Http/Controllers/Api/AssetModelsController.php index c1c46538db..e77c648b34 100644 --- a/app/Http/Controllers/Api/AssetModelsController.php +++ b/app/Http/Controllers/Api/AssetModelsController.php @@ -46,6 +46,7 @@ class AssetModelsController extends Controller 'requestable', 'assets_count', 'category', + 'fieldset', ]; $assetmodels = AssetModel::select([ @@ -94,6 +95,9 @@ class AssetModelsController extends Controller case 'category': $assetmodels->OrderCategory($order); break; + case 'fieldset': + $assetmodels->OrderFieldset($order); + break; default: $assetmodels->orderBy($sort, $order); break; diff --git a/app/Models/AssetModel.php b/app/Models/AssetModel.php index e0b056fc9f..f94c6f8eac 100755 --- a/app/Models/AssetModel.php +++ b/app/Models/AssetModel.php @@ -291,4 +291,9 @@ class AssetModel extends SnipeModel { return $query->leftJoin('categories', 'models.category_id', '=', 'categories.id')->orderBy('categories.name', $order); } + + public function scopeOrderFieldset($query, $order) + { + return $query->leftJoin('custom_fieldsets', 'models.fieldset_id', '=', 'custom_fieldsets.id')->orderBy('custom_fieldsets.name', $order); + } }