#21 add planned closing time to food order
This commit is contained in:
parent
634f13d968
commit
b479fbf5ed
5 changed files with 11 additions and 3 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Repository\FoodOrderRepository;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
@ -36,6 +37,7 @@ class FoodOrder
|
|||
public function __construct()
|
||||
{
|
||||
$this->orderItems = new ArrayCollection;
|
||||
$this->open();
|
||||
}
|
||||
|
||||
public function getId(): Ulid|null
|
||||
|
@ -62,7 +64,7 @@ class FoodOrder
|
|||
|
||||
public function isClosed(): bool
|
||||
{
|
||||
return $this->closedAt instanceof DateTimeImmutable;
|
||||
return $this->closedAt instanceof DateTimeImmutable && $this->closedAt->getTimestamp() <= (new DateTimeImmutable)->getTimestamp();
|
||||
}
|
||||
|
||||
public function close(): static
|
||||
|
@ -72,7 +74,8 @@ class FoodOrder
|
|||
|
||||
public function open(): static
|
||||
{
|
||||
return $this->setClosedAt(null);
|
||||
$this->closedAt = (new DateTimeImmutable)->add(new DateInterval('PT1H'));
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFoodVendor(): FoodVendor|null
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue