From 53d5f8518b08ba3f222b3ad2529ce6a5eccaefb2 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sun, 20 Dec 2020 20:45:49 +0100 Subject: [PATCH] Questions: Change sorting --- src/Controllers/Admin/QuestionsController.php | 2 +- src/Controllers/QuestionsController.php | 3 ++- tests/Unit/Controllers/QuestionsControllerTest.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Controllers/Admin/QuestionsController.php b/src/Controllers/Admin/QuestionsController.php index f1ac77f7..8cae429c 100644 --- a/src/Controllers/Admin/QuestionsController.php +++ b/src/Controllers/Admin/QuestionsController.php @@ -66,7 +66,7 @@ class QuestionsController extends BaseController public function index(): Response { $questions = $this->question - ->orderBy('answer') + ->orderBy('answered_at') ->orderByDesc('created_at') ->get(); $this->cleanupModelNullValues($questions); diff --git a/src/Controllers/QuestionsController.php b/src/Controllers/QuestionsController.php index 808ea360..ccc26766 100644 --- a/src/Controllers/QuestionsController.php +++ b/src/Controllers/QuestionsController.php @@ -63,7 +63,8 @@ class QuestionsController extends BaseController { $questions = $this->question ->whereUserId($this->auth->user()->id) - ->orderByDesc('created_at') + ->orderByDesc('answered_at') + ->orderBy('created_at') ->get(); $this->cleanupModelNullValues($questions); diff --git a/tests/Unit/Controllers/QuestionsControllerTest.php b/tests/Unit/Controllers/QuestionsControllerTest.php index e31d9bed..193bcdf2 100644 --- a/tests/Unit/Controllers/QuestionsControllerTest.php +++ b/tests/Unit/Controllers/QuestionsControllerTest.php @@ -35,7 +35,7 @@ class QuestionsControllerTest extends ControllerTest $this->assertEquals('pages/questions/overview.twig', $view); $this->assertArrayHasKey('questions', $data); - $this->assertEquals('Lorem?', $data['questions'][0]->text); + $this->assertEquals('Foo?', $data['questions'][0]->text); return $this->response; });