updatedAt = $updatedAt; } #[ORM\OneToMany(mappedBy: 'order', targetEntity: OrderItem::class, cascade: ['persist', 'remove'])] private Collection $orderItems; #[ORM\Column(nullable: false, enumType: OrderStatus::class, options: [ 'default' => OrderStatus::NEW, ])] private OrderStatus $status = OrderStatus::NEW; public function __construct( ) { $this->createdAt = new DateTimeImmutable(); $this->updatedAt = new DateTimeImmutable(); $this->orderItems = new ArrayCollection(); } public function getId(): null|int { return $this->id; } public function getStatus(): OrderStatus { return $this->status; } public function setStatus(OrderStatus $status): self { $this->status = $status; $this->updateTimestamp(); return $this; } public function getCreatedAt(): DateTimeImmutable { return $this->createdAt; } public function getUpdatedAt(): DateTimeImmutable { return $this->updatedAt; } /** * @return Collection */ public function getOrderItems(): Collection { return $this->orderItems; } public function addOrderItem(OrderItem $orderItem): self { if (!$this->orderItems->contains($orderItem)) { $this->orderItems[] = $orderItem; $orderItem->setOrder($this); } return $this; } public function removeOrderItem(OrderItem $orderItem): self { // set the owning side to null (unless already changed) if ($this->orderItems->removeElement($orderItem) && $orderItem->getOrder() === $this) { $orderItem->setOrder(null); } return $this; } private function updateTimestamp(): void { $this->updatedAt = new DateTimeImmutable(); } }