<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Greg0ire\Enum\Bridge\Symfony\Validator\Constraint\Enum as EnumAssert;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserLikeRepository")
*/
class UserLike
{
public const ARTICLE_TYPE = 'article';
public const REVIEW_TYPE = 'review';
public const BLOG_TYPE = 'blog';
public const NEWSROOM_TYPE = 'newsroom';
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="userLikes")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Article", inversedBy="userLikes")
* @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
*/
private $article;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Blog", inversedBy="userLikes")
* @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
*/
private $blog;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Newsroom", inversedBy="userLikes")
* @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
*/
private $newsroom;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Review", inversedBy="userLikes")
* @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
*/
private $review;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @var string
*
* @ORM\Column(type="string", length=64, nullable=false)
* @Assert\Length(max=64)
* @EnumAssert(class="App\Enum\UserLikeType")
* @Assert\NotBlank()
*/
private $type;
/**
* UserLike constructor.
*
* @throws \Exception
*/
public function __construct()
{
$this->createdAt = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?user
{
return $this->user;
}
public function setUser(?user $user): self
{
$this->user = $user;
return $this;
}
public function getArticle(): ?Article
{
return $this->article;
}
public function setArticle(?Article $article): self
{
$this->article = $article;
return $this;
}
public function getBlog(): ?Blog
{
return $this->blog;
}
public function setBlog(?Blog $blog): self
{
$this->blog = $blog;
return $this;
}
public function getNewsroom(): ?Newsroom
{
return $this->newsroom;
}
public function setNewsroom(?Newsroom $newsroom): self
{
$this->newsroom = $newsroom;
return $this;
}
public function getReview(): ?Review
{
return $this->review;
}
public function setReview(?Review $review): self
{
$this->review = $review;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
}