Skip to content

Commit

Permalink
Merge pull request #13678 from spencerrlongg/bug/sc-23596
Browse files Browse the repository at this point in the history
Fieldset Properly Sortable in Asset Models Table
  • Loading branch information
snipe authored Sep 28, 2023
2 parents 3b4004a + a54fab5 commit f16e81e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/Http/Controllers/Api/AssetModelsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function index(Request $request)
'requestable',
'assets_count',
'category',
'fieldset',
];

$assetmodels = AssetModel::select([
Expand Down Expand Up @@ -94,6 +95,9 @@ public function index(Request $request)
case 'category':
$assetmodels->OrderCategory($order);
break;
case 'fieldset':
$assetmodels->OrderFieldset($order);
break;
default:
$assetmodels->orderBy($sort, $order);
break;
Expand Down
5 changes: 5 additions & 0 deletions app/Models/AssetModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,9 @@ public function scopeOrderCategory($query, $order)
{
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);
}
}

0 comments on commit f16e81e

Please sign in to comment.