From b441c9350bd33db10eaae5e5e1fe226c8073d76e Mon Sep 17 00:00:00 2001 From: khalil Abu jayab <74875624+khalilJayab@users.noreply.github.com> Date: Tue, 18 Jul 2023 00:44:02 +0300 Subject: [PATCH 1/5] add filter to journal --- app/Http/Controllers/JournalController.php | 20 ++++- .../js/components/journal/JournalList.vue | 85 ++++++++++++++----- 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, 273 insertions(+), 21 deletions(-) diff --git a/app/Http/Controllers/JournalController.php b/app/Http/Controllers/JournalController.php index ccd03e930eb..95fc52e8c39 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..826a7b69038 100644 --- a/resources/js/components/journal/JournalList.vue +++ b/resources/js/components/journal/JournalList.vue @@ -1,29 +1,63 @@