From d0f18647ed2f0b20951facde01c9314b112e90a7 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 21 Dec 2022 19:45:27 +1100 Subject: [PATCH] Add finer grained resolution to created_at query --- app/Filters/QueryFilters.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/app/Filters/QueryFilters.php b/app/Filters/QueryFilters.php index 211f405de0..6d7039152c 100644 --- a/app/Filters/QueryFilters.php +++ b/app/Filters/QueryFilters.php @@ -174,25 +174,22 @@ abstract class QueryFilters } } - public function created_at($value = '') + public function created_at($value) { - - if($value == '') - return $this->builder; + $created_at = $value ? (int) $value : 0; - try{ + $created_at = date('Y-m-d H:i:s', $value); - $created_at = Carbon::parse($value)->timestamp; + if(is_string($created_at)){ - return $this->builder->where('created_at', '>=', $created_at); + $created_at = strtotime(str_replace("/","-",$created_at)); + + if(!$created_at) + return $this->builder; } - catch(\Exception $e) { - return $this->builder; - - } - + return $this->builder->where('created_at', '>=', $created_at); } public function is_deleted($value)