From 6ec0735a226ef45863b343b2270de9f3f840e429 Mon Sep 17 00:00:00 2001 From: khalil Abu jayab <74875624+khalilJayab@users.noreply.github.com> Date: Mon, 6 Nov 2023 23:12:59 +0200 Subject: [PATCH] feat: add filter to journal (#6758) Co-authored-by: Alexis Saettler --- app/Http/Controllers/JournalController.php | 20 +++- .../js/components/journal/JournalList.vue | 107 ++++++++++++++---- resources/lang/ar/journal.php | 7 ++ resources/lang/cs/journal.php | 7 ++ resources/lang/da/journal.php | 7 ++ resources/lang/de/journal.php | 7 ++ resources/lang/el/journal.php | 7 ++ resources/lang/en-GB/journal.php | 7 ++ resources/lang/en/journal.php | 7 ++ resources/lang/es/journal.php | 7 ++ resources/lang/fa/journal.php | 7 ++ resources/lang/fi/journal.php | 7 ++ resources/lang/fr/journal.php | 7 ++ resources/lang/he/journal.php | 7 ++ resources/lang/hr/journal.php | 7 ++ resources/lang/id/journal.php | 7 ++ resources/lang/it/journal.php | 7 ++ resources/lang/ja/journal.php | 7 ++ resources/lang/nl/journal.php | 7 ++ resources/lang/no/journal.php | 7 ++ resources/lang/pt-BR/journal.php | 7 ++ resources/lang/pt/journal.php | 7 ++ resources/lang/ru/journal.php | 7 ++ resources/lang/sv/journal.php | 7 ++ resources/lang/tr/journal.php | 7 ++ resources/lang/uk/journal.php | 7 ++ resources/lang/vi/journal.php | 7 ++ resources/lang/zh-TW/journal.php | 7 ++ resources/lang/zh/journal.php | 7 ++ 29 files changed, 294 insertions(+), 22 deletions(-) diff --git a/app/Http/Controllers/JournalController.php b/app/Http/Controllers/JournalController.php index dbf92389e50..e14f383ec98 100644 --- a/app/Http/Controllers/JournalController.php +++ b/app/Http/Controllers/JournalController.php @@ -28,10 +28,26 @@ public function index() * * @return array */ - public function list() + public function list(Request $request) { + + $startDate = $request->input('start_date'); + $endDate = $request->input('end_date'); + $sortBy = $request->input('sort_by', 'created_at'); + $sortOrder = $request->input('sort_order', 'desc'); + $perPage = $request->input('per_page', 30); + $entries = collect([]); - $journalEntries = auth()->user()->account->journalEntries()->paginate(30); + + $journalEntriesQuery = auth()->user()->account->journalEntries(); + + if ($startDate && $endDate) { + $journalEntriesQuery->whereDate('date', '>=', $startDate) + ->whereDate('date', '<=', $endDate); + } + $journalEntries = $journalEntriesQuery->orderBy($sortBy, $sortOrder) + ->paginate($perPage); + // this is needed to determine if we need to display the calendar // (month + year) next to the journal entry diff --git a/resources/js/components/journal/JournalList.vue b/resources/js/components/journal/JournalList.vue index a8c4932df71..c5e0868a553 100644 --- a/resources/js/components/journal/JournalList.vue +++ b/resources/js/components/journal/JournalList.vue @@ -1,29 +1,74 @@