src/Entity/UserFavorites.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserFavoritesRepository;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass=UserFavoritesRepository::class)
  8.  * @ORM\HasLifecycleCallbacks()
  9.  */
  10. class UserFavorites
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\ManyToOne(targetEntity=User::class,inversedBy="favorites")
  20.      */
  21.     private $user;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     private $entity;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      */
  29.     private $entityId;
  30.     /**
  31.      * @ORM\Column(type="datetime", nullable=true, options={"default": "CURRENT_TIMESTAMP"})
  32.      */
  33.     private $createdAt;
  34.     /**
  35.      * @ORM\Column(type="datetime", nullable=true, options={"default": "CURRENT_TIMESTAMP"})
  36.      */
  37.     private $updatedAt;
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getUser(): ?User
  43.     {
  44.         return $this->user;
  45.     }
  46.     public function setUser(?User $user): self
  47.     {
  48.         $this->user $user;
  49.         return $this;
  50.     }
  51.     public function getEntity(): ?string
  52.     {
  53.         return $this->entity;
  54.     }
  55.     public function setEntity(string $entity): self
  56.     {
  57.         $this->entity $entity;
  58.         return $this;
  59.     }
  60.     public function getEntityId(): ?string
  61.     {
  62.         return $this->entityId;
  63.     }
  64.     public function setEntityId(string $entityId): self
  65.     {
  66.         $this->entityId $entityId;
  67.         return $this;
  68.     }
  69.     public function getCreatedAt() :?DateTime
  70.     {
  71.         return $this->createdAt;
  72.     }
  73.     public function setCreatedAt(DateTime $createdAt): self
  74.     {
  75.         $this->createdAt $createdAt;
  76.         return $this;
  77.     }
  78.     public function getUpdatedAt() :?DateTime
  79.     {
  80.         return $this->updatedAt;
  81.     }
  82.     public function setUpdatedAt(DateTime $updatedAt): self
  83.     {
  84.         $this->updatedAt $updatedAt;
  85.         return $this;
  86.     }
  87.     /**
  88.      * @ORM\PrePersist
  89.      * @ORM\PreUpdate
  90.      */
  91.     public function updatedTimestamps(): void
  92.     {
  93.         $dateTimeNow = new DateTime('now');
  94.         $this->setUpdatedAt($dateTimeNow);
  95.         if ($this->getCreatedAt() === null) {
  96.             $this->setCreatedAt($dateTimeNow);
  97.         }
  98.     }
  99. }