SHARE
TWEET

TimestampableTrait

drestrepo Jun 30th, 2020 961 in 4 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. declare(strict_types=1);
  3.  
  4. namespace App\Entity\Traits;
  5.  
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use JMS\Serializer\Annotation as Serializer;
  9.  
  10. trait TimestampableTrait
  11. {
  12.  
  13.     /**
  14.      * @var \DateTime
  15.      * @ORM\Column(name="created_at", type="datetime")
  16.      * @Gedmo\Timestampable(on="create")
  17.      * @Serializer\Expose()
  18.      */
  19.     protected $createdAt;
  20.  
  21.     /**
  22.      * @var \DateTime
  23.      * @ORM\Column(name="updated_at", type="datetime")
  24.      * @Gedmo\Timestampable(on="update")
  25.      * @Serializer\Expose()
  26.      */
  27.     protected $updatedAt;
  28.  
  29.     /**
  30.      * @return \DateTime
  31.      */
  32.     public function getCreatedAt() : \DateTime
  33.     {
  34.         return $this->createdAt;
  35.     }
  36.  
  37.     /**
  38.      * @return \DateTime
  39.      */
  40.     public function getUpdatedAt() : \DateTime
  41.     {
  42.         return $this->updatedAt;
  43.     }
  44.  
  45.     /**
  46.      * @param \DateTime $createdAt
  47.      */
  48.     public function setCreatedAt(\DateTime $createdAt): void
  49.     {
  50.         $this->createdAt = $createdAt;
  51.     }
  52.  
  53.     /**
  54.      * @param \DateTime $updatedAt
  55.      */
  56.     public function setUpdatedAt(\DateTime $updatedAt): void
  57.     {
  58.         $this->updatedAt = $updatedAt;
  59.     }
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top