From 797dc193bd284faca26d8369265daf6adbe669a0 Mon Sep 17 00:00:00 2001 From: James Collins Date: Wed, 25 Jan 2023 12:43:21 +1000 Subject: [PATCH] fix descending sort option --- app/Filters/FilterAbstract.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Filters/FilterAbstract.php b/app/Filters/FilterAbstract.php index 8c72e50..ee93886 100644 --- a/app/Filters/FilterAbstract.php +++ b/app/Filters/FilterAbstract.php @@ -314,7 +314,14 @@ abstract class FilterAbstract /* Remove non-viewable attributes from sort list */ if (count($sortList) > 0) { - $sortList = array_intersect($attributes, $sortList); + $sortList = array_filter($sortList, function ($item) use ($attributes) { + $parsedItem = $item; + if (substr($parsedItem, 0, 1) === '-') { + $parsedItem = substr($parsedItem, 1); + } + + return in_array($parsedItem, $attributes); + }); } /* Do we have any sort element left? */