diff --git a/src/Casts/DateTimeInterfaceCast.php b/src/Casts/DateTimeInterfaceCast.php index 4003d01e..2a1b97ee 100644 --- a/src/Casts/DateTimeInterfaceCast.php +++ b/src/Casts/DateTimeInterfaceCast.php @@ -14,7 +14,8 @@ public function __construct( protected null|string|array $format = null, protected ?string $type = null, protected ?string $setTimeZone = null, - protected ?string $timeZone = null + protected ?string $timeZone = null, + protected bool $setMidnight = false ) { } @@ -54,7 +55,12 @@ protected function castValue( $this->setTimeZone ??= config('data.date_timezone'); if ($this->setTimeZone) { - return $datetime->setTimezone(new DateTimeZone($this->setTimeZone)); + $datetime = $datetime->setTimezone(new DateTimeZone($this->setTimeZone)); + } + + //Force the time to 00:00:00.000 + if ($this->setMidnight) { + $datetime = $datetime->setTime(0, 0); } return $datetime; diff --git a/src/Support/Caching/DataStructureCache.php b/src/Support/Caching/DataStructureCache.php index 13d8c772..0968cdc1 100644 --- a/src/Support/Caching/DataStructureCache.php +++ b/src/Support/Caching/DataStructureCache.php @@ -17,7 +17,7 @@ class DataStructureCache public function __construct( protected array $cacheConfig, ) { - $this->store = cache()->store(($this->cacheConfig['store'] ?? null))?->getStore(); + $this->store = cache()->store(($this->cacheConfig['store'] ?? null))->getStore(); $this->prefix = ($this->cacheConfig['prefix'] ?? '') ? "{$this->cacheConfig['prefix']}." : ''; $this->duration = $this->cacheConfig['duration'] ?? null; }