From 03a22132e430adc43845da9a6b5f2dacbeafd311 Mon Sep 17 00:00:00 2001 From: Kamil Date: Thu, 19 Jul 2018 21:22:21 +0200 Subject: Add search within a range of dates for completion and modification --- app/Filter/BaseDateRangeFilter.php | 8 +++--- app/Filter/TaskCompletionDateRangeFilter.php | 38 ++++++++++++++++++++++++++ app/Filter/TaskModificationDateRangeFilter.php | 38 ++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 app/Filter/TaskCompletionDateRangeFilter.php create mode 100644 app/Filter/TaskModificationDateRangeFilter.php (limited to 'app/Filter') diff --git a/app/Filter/BaseDateRangeFilter.php b/app/Filter/BaseDateRangeFilter.php index 336f8c8e..fcff0d4c 100644 --- a/app/Filter/BaseDateRangeFilter.php +++ b/app/Filter/BaseDateRangeFilter.php @@ -42,10 +42,10 @@ abstract class BaseDateRangeFilter extends BaseFilter protected function applyDateFilter($field) { $dates = explode('..', $this->value); - - if(count($dates)=== 2){ - $timestampFrom = $this->dateParser->getTimestamp($dates[0]); - $timestampTo = $this->dateParser->getTimestamp($dates[1]); + + if(count($dates)=== 2){ + $timestampFrom = $this->dateParser->getTimestamp($dates[0]." 00:00"); + $timestampTo = $this->dateParser->getTimestamp($dates[1]." 00:00"); $this->query->gte($field, $timestampFrom); $this->query->lte($field, $timestampTo + 86399); diff --git a/app/Filter/TaskCompletionDateRangeFilter.php b/app/Filter/TaskCompletionDateRangeFilter.php new file mode 100644 index 00000000..9272cc1e --- /dev/null +++ b/app/Filter/TaskCompletionDateRangeFilter.php @@ -0,0 +1,38 @@ +applyDateFilter(TaskModel::TABLE.'.date_completed'); + return $this; + } +} diff --git a/app/Filter/TaskModificationDateRangeFilter.php b/app/Filter/TaskModificationDateRangeFilter.php new file mode 100644 index 00000000..3daa2b59 --- /dev/null +++ b/app/Filter/TaskModificationDateRangeFilter.php @@ -0,0 +1,38 @@ +applyDateFilter(TaskModel::TABLE.'.date_modification'); + return $this; + } +} -- cgit v1.2.3