src/Entity/PostLike.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Interfaces\ILikeable;
  4. use App\Repository\PostLikeRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassPostLikeRepository::class)]
  7. class PostLike implements ILikeable
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column(type'integer')]
  12.     private $id;
  13.     #[ORM\ManyToOne(targetEntityUser::class)]
  14.     #[ORM\JoinColumn(nullablefalse)]
  15.     private $user;
  16.     #[ORM\ManyToOne(targetEntityPost::class, inversedBy'postLikes')]
  17.     #[ORM\JoinColumn(nullablefalse)]
  18.     private $post;
  19.     #[ORM\Column(type'datetime')]
  20.     private $createdAt;
  21.     #[ORM\Column(type'datetime')]
  22.     private $updatedAt;
  23.     #[ORM\Column(type'string'length20nullabletrue)]
  24.     private $emotion;
  25.     public function __construct()
  26.     {
  27.         $this->createdAt = new \DateTime();
  28.         $this->updatedAt = new \DateTime();
  29.     }
  30.     public function getId(): ?int
  31.     {
  32.         return $this->id;
  33.     }
  34.     public function getUser(): ?User
  35.     {
  36.         return $this->user;
  37.     }
  38.     public function setUser(?User $user): self
  39.     {
  40.         $this->user $user;
  41.         return $this;
  42.     }
  43.     public function getPost(): ?Post
  44.     {
  45.         return $this->post;
  46.     }
  47.     public function setPost(?Post $post): self
  48.     {
  49.         $this->post $post;
  50.         return $this;
  51.     }
  52.     public function getCreatedAt(): ?\DateTimeInterface
  53.     {
  54.         return $this->createdAt;
  55.     }
  56.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  57.     {
  58.         $this->createdAt $createdAt;
  59.         return $this;
  60.     }
  61.     public function getUpdatedAt(): ?\DateTimeInterface
  62.     {
  63.         return $this->updatedAt;
  64.     }
  65.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  66.     {
  67.         $this->updatedAt $updatedAt;
  68.         return $this;
  69.     }
  70.     public function getEmotion(): ?string
  71.     {
  72.         return $this->emotion ?? 'like';
  73.     }
  74.     public function setEmotion(?string $emotion): self
  75.     {
  76.         $this->emotion $emotion;
  77.         return $this;
  78.     }
  79. }