Permalink
Browse files

add methods to auto set the created at and updated at timestamps

  • Loading branch information...
1 parent ceabac3 commit eea928fff9c6c367e9dcb4c2c7a47cde82c7c4bb @iampersistent iampersistent committed Jul 29, 2012
Showing with 13 additions and 0 deletions.
  1. +13 −0 lib/Vespolina/Entity/Order/Cart.php
@@ -144,4 +144,17 @@ public function setUpdatedAt(\DateTime $updatedAt)
{
$this->updatedAt = $updatedAt;
}
+
+ public function autoSetCreatedAt()
+ {
+ if (null === $this->createdAt) {
+ $this->createdAt = new \DateTime();
+ }
+ $this->autoSetUpdatedAt();
+ }
+
+ public function autoSetUpdateAt()
+ {
+ $this->updateAt = new \DateTime();
+ }
}

0 comments on commit eea928f

Please sign in to comment.