From d2c2b1837c06cbacd992af94665f6c24d73bcfb2 Mon Sep 17 00:00:00 2001 From: FreeScout Date: Tue, 6 Dec 2022 22:51:16 -0800 Subject: [PATCH] Allow to sort search results by columns --- app/Conversation.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Conversation.php b/app/Conversation.php index 5dfd7e5c..986e916e 100644 --- a/app/Conversation.php +++ b/app/Conversation.php @@ -2199,7 +2199,11 @@ class Conversation extends Model $query_conversations = \Eventy::filter('search.conversations.apply_filters', $query_conversations, $filters, $q); - $query_conversations->orderBy('conversations.last_reply_at', 'DESC'); + $sorting = Conversation::getConvTableSorting(); + if ($sorting['sort_by'] == 'date') { + $sorting['sort_by'] = 'last_reply_at'; + } + $query_conversations->orderBy($sorting['sort_by'], $sorting['order']); return $query_conversations; }