src/Entity/UserLike.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Greg0ire\Enum\Bridge\Symfony\Validator\Constraint\Enum as EnumAssert;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\UserLikeRepository")
  8.  */
  9. class UserLike
  10. {
  11.     public const ARTICLE_TYPE 'article';
  12.     public const REVIEW_TYPE 'review';
  13.     public const BLOG_TYPE 'blog';
  14.     public const NEWSROOM_TYPE 'newsroom';
  15.     /**
  16.      * @ORM\Id()
  17.      * @ORM\GeneratedValue()
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="userLikes")
  23.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  24.      */
  25.     private $user;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity="App\Entity\Article", inversedBy="userLikes")
  28.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  29.      */
  30.     private $article;
  31.     /**
  32.      * @ORM\ManyToOne(targetEntity="App\Entity\Blog", inversedBy="userLikes")
  33.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  34.      */
  35.     private $blog;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity="App\Entity\Newsroom", inversedBy="userLikes")
  38.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  39.      */
  40.     private $newsroom;
  41.     /**
  42.      * @ORM\ManyToOne(targetEntity="App\Entity\Review", inversedBy="userLikes")
  43.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  44.      */
  45.     private $review;
  46.     /**
  47.      * @ORM\Column(type="datetime")
  48.      */
  49.     private $createdAt;
  50.     /**
  51.      * @var string
  52.      *
  53.      * @ORM\Column(type="string", length=64, nullable=false)
  54.      * @Assert\Length(max=64)
  55.      * @EnumAssert(class="App\Enum\UserLikeType")
  56.      * @Assert\NotBlank()
  57.      */
  58.     private $type;
  59.     /**
  60.      * UserLike constructor.
  61.      *
  62.      * @throws \Exception
  63.      */
  64.     public function __construct()
  65.     {
  66.         $this->createdAt = new \DateTime();
  67.     }
  68.     public function getId(): ?int
  69.     {
  70.         return $this->id;
  71.     }
  72.     public function getUser(): ?user
  73.     {
  74.         return $this->user;
  75.     }
  76.     public function setUser(?user $user): self
  77.     {
  78.         $this->user $user;
  79.         return $this;
  80.     }
  81.     public function getArticle(): ?Article
  82.     {
  83.         return $this->article;
  84.     }
  85.     public function setArticle(?Article $article): self
  86.     {
  87.         $this->article $article;
  88.         return $this;
  89.     }
  90.     public function getBlog(): ?Blog
  91.     {
  92.         return $this->blog;
  93.     }
  94.     public function setBlog(?Blog $blog): self
  95.     {
  96.         $this->blog $blog;
  97.         return $this;
  98.     }
  99.     public function getNewsroom(): ?Newsroom
  100.     {
  101.         return $this->newsroom;
  102.     }
  103.     public function setNewsroom(?Newsroom $newsroom): self
  104.     {
  105.         $this->newsroom $newsroom;
  106.         return $this;
  107.     }
  108.     public function getReview(): ?Review
  109.     {
  110.         return $this->review;
  111.     }
  112.     public function setReview(?Review $review): self
  113.     {
  114.         $this->review $review;
  115.         return $this;
  116.     }
  117.     public function getCreatedAt(): ?\DateTimeInterface
  118.     {
  119.         return $this->createdAt;
  120.     }
  121.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  122.     {
  123.         $this->createdAt $createdAt;
  124.         return $this;
  125.     }
  126.     public function getType(): ?string
  127.     {
  128.         return $this->type;
  129.     }
  130.     public function setType(string $type): self
  131.     {
  132.         $this->type $type;
  133.         return $this;
  134.     }
  135. }