From 5a78116b46fbf8df90938176406485c68944f80e Mon Sep 17 00:00:00 2001 From: Calum Date: Wed, 30 Mar 2022 15:59:36 +0100 Subject: [PATCH] pass sorting options to getConversationsList --- src/Models/Conversation.php | 4 ++-- src/Services/ConversationService.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Models/Conversation.php b/src/Models/Conversation.php index 56ab219..7a27a43 100644 --- a/src/Models/Conversation.php +++ b/src/Models/Conversation.php @@ -373,8 +373,8 @@ private function getConversationsList(Model $participant, $options) } return $paginator - ->orderBy('c.updated_at', 'DESC') - ->orderBy('c.id', 'DESC') + ->orderBy('c.updated_at', $options['sorting']) + ->orderBy('c.id', $options['sorting']) ->distinct('c.id') ->paginate($options['perPage'], [$this->tablePrefix.'participation.*', 'c.*'], $options['pageName'], $options['page']); } diff --git a/src/Services/ConversationService.php b/src/Services/ConversationService.php index 04947a4..83b4bcb 100644 --- a/src/Services/ConversationService.php +++ b/src/Services/ConversationService.php @@ -110,6 +110,7 @@ public function get() 'page' => $this->page, 'pageName' => 'page', 'filters' => $this->filters, + 'sorting' => $this->sorting, ]); }