From 7da5eb9f72d65bbf975700536a0a24e5caff0c42 Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Wed, 17 Dec 2025 16:50:56 +0100 Subject: [PATCH] I cart date setters --- src/Models/Cart.php | 23 ++++++++++++++--------- src/Models/CartItem.php | 8 ++++---- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Models/Cart.php b/src/Models/Cart.php index d53bc1a..bfcb9db 100644 --- a/src/Models/Cart.php +++ b/src/Models/Cart.php @@ -193,13 +193,16 @@ class Cart extends Model * @throws InvalidDateRangeException * @throws NotEnoughAvailableInTimespanException */ - public function setDates(\DateTimeInterface|string $from, \DateTimeInterface|string $until, bool $validateAvailability = true): self - { + public function setDates( + \DateTimeInterface|string|int|float $from, + \DateTimeInterface|string|int|float $until, + bool $validateAvailability = true + ): self { // Parse string dates using Carbon - if (is_string($from)) { + if (is_string($from) || is_numeric($from)) { $from = Carbon::parse($from); } - if (is_string($until)) { + if (is_string($until) || is_numeric($until)) { $until = Carbon::parse($until); } @@ -228,10 +231,12 @@ class Cart extends Model * @throws InvalidDateRangeException * @throws NotEnoughAvailableInTimespanException */ - public function setFromDate(\DateTimeInterface|string $from, bool $validateAvailability = true): self - { + public function setFromDate( + \DateTimeInterface|string|int|float $from, + bool $validateAvailability = true + ): self { // Parse string dates using Carbon - if (is_string($from)) { + if (is_string($from) || is_numeric($from)) { $from = Carbon::parse($from); } @@ -257,10 +262,10 @@ class Cart extends Model * @throws InvalidDateRangeException * @throws NotEnoughAvailableInTimespanException */ - public function setUntilDate(\DateTimeInterface|string $until, bool $validateAvailability = true): self + public function setUntilDate(\DateTimeInterface|string|int|float $until, bool $validateAvailability = true): self { // Parse string dates using Carbon - if (is_string($until)) { + if (is_string($until) || is_numeric($until)) { $until = Carbon::parse($until); } diff --git a/src/Models/CartItem.php b/src/Models/CartItem.php index 5738f63..d9c0b74 100644 --- a/src/Models/CartItem.php +++ b/src/Models/CartItem.php @@ -432,10 +432,10 @@ class CartItem extends Model * @return $this * @throws InvalidDateRangeException */ - public function setFromDate(\DateTimeInterface|string $from): self + public function setFromDate(\DateTimeInterface|string|int|float $from): self { // Parse string dates using Carbon - if (is_string($from)) { + if (is_string($from) || is_numeric($from)) { $from = \Carbon\Carbon::parse($from); } @@ -464,10 +464,10 @@ class CartItem extends Model * @return $this * @throws InvalidDateRangeException */ - public function setUntilDate(\DateTimeInterface|string $until): self + public function setUntilDate(\DateTimeInterface|string|int|float $until): self { // Parse string dates using Carbon - if (is_string($until)) { + if (is_string($until) || is_numeric($until)) { $until = \Carbon\Carbon::parse($until); }