src/Entity/BaseDateEntity.php line 16

  1. <?php
  2. /*
  3.  *  @author Guerby Duval <info@tranzaksyon.com>
  4.  *  @link https://tranzaksyon.com
  5.  *  @copyright You are not allowed to remove this author "Guerby Duval <info@tranzaksyon.com>", the link "https://tranzaksyon.com" neither this copyright.
  6.  */
  7. namespace App\Entity;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Doctrine\ORM\Mapping\MappedSuperclass;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. #[MappedSuperclass]
  13. abstract class BaseDateEntity
  14. {
  15.     #[ORM\Column(typeTypes::DATETIME_MUTABLEoptions: ['default' => 'CURRENT_TIMESTAMP'])]
  16.     #[Groups(['general_doc_out'])]
  17.     private ?\DateTimeInterface $creationDate;
  18.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  19.     #[Groups(['general_doc_out'])]
  20.     private ?\DateTimeInterface $dateUpdate;
  21.     public function __construct()
  22.     {
  23.         $this->creationDate = new \DateTime();
  24.         $this->dateUpdate = new \DateTime();
  25.     }
  26.     public function getCreationDate(): ?\DateTimeInterface
  27.     {
  28.         return $this->creationDate;
  29.     }
  30.     public function setCreationDate(\DateTimeInterface $creationDate): self
  31.     {
  32.         $this->creationDate $creationDate;
  33.         return $this;
  34.     }
  35.     public function getDateUpdate(): ?\DateTimeInterface
  36.     {
  37.         return $this->dateUpdate;
  38.     }
  39.     public function setDateUpdate(\DateTimeInterface $dateUpdate): self
  40.     {
  41.         $this->dateUpdate $dateUpdate;
  42.         return $this;
  43.     }
  44. }