From ec8a4d33338af60e8d367e73d36092709d406118 Mon Sep 17 00:00:00 2001 From: Saifallak Date: Sun, 26 May 2024 19:19:46 +0300 Subject: [PATCH] Pass sorting options through to getConversationsList #301 --- 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 730f2c4..3e30084 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'] ?? 'DESC') + ->orderBy('c.id', $options['sorting'] ?? 'DESC') ->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, ]); }