diff --git a/src/Entity/CreatableUpdateableTrait.php b/src/Entity/CreatableUpdateableTrait.php new file mode 100644 index 0000000..86f420f --- /dev/null +++ b/src/Entity/CreatableUpdateableTrait.php @@ -0,0 +1,50 @@ +createdAt; + } + + final public function setCreatedAt(\DateTimeImmutable $createdAt): self + { + $this->createdAt = $createdAt; + + return $this; + } + + final public function getUpdatedAt(): ?\DateTimeImmutable + { + return $this->updatedAt; + } + + final public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self + { + $this->updatedAt = $updatedAt; + + return $this; + } + + #[ORM\PrePersist] + final public function setCreatedAtValue(): void + { + $this->createdAt = new \DateTimeImmutable(); + } + + #[ORM\PreUpdate] + final public function setUpdatedAtValue(): void + { + $this->updatedAt = new \DateTimeImmutable(); + } +}