src/Entity/Comment.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CommentRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. /**
  7.  * @ORM\Entity(repositoryClass=CommentRepository::class)
  8.  */
  9. class Comment
  10. {
  11.     /**
  12.      * @ORM\Id
  13.      * @ORM\GeneratedValue
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="comments")
  19.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  20.      */
  21.     private $user;
  22.     /**
  23.      * @ORM\ManyToOne(targetEntity=Photo::class, inversedBy="comments")
  24.      * @ORM\JoinColumn(onDelete="CASCADE")
  25.      */
  26.     private $photo;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity=Influencer::class, inversedBy="comments")
  29.      * @ORM\JoinColumn(onDelete="CASCADE")
  30.      */
  31.     private $influencer;
  32.     /**
  33.      * @ORM\Column(type="text")
  34.      * @Assert\NotBlank()
  35.      * @Assert\Length(
  36.      *      min = 3,
  37.      *      max = 500,
  38.      *      minMessage = "Comment must be at least {{ limit }} characters long",
  39.      *      maxMessage = "Comment cannot be longer than {{ limit }} characters"
  40.      * )
  41.      * @Assert\Regex(
  42.      *   pattern = "#^((?!https).)*#"
  43.      * )
  44.      */
  45.     private $comment;
  46.     /**
  47.      * @ORM\Column(type="datetime_immutable")
  48.      */
  49.     private $created_at;
  50.     /**
  51.      * @ORM\Column(type="datetime")
  52.      */
  53.     private $updated_at;
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity=Video::class, inversedBy="comments")
  56.      * @ORM\JoinColumn(onDelete="CASCADE")
  57.      */
  58.     private $video;
  59.     /**
  60.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="profil_comments")
  61.      * @ORM\JoinColumn(onDelete="CASCADE")
  62.      */
  63.     private $to_user;
  64.     public function __construct()
  65.     {
  66.         $this->created_at = new \DateTimeImmutable();
  67.         $this->updated_at = new \DateTime();
  68.     }
  69.     public function getId(): ?int
  70.     {
  71.         return $this->id;
  72.     }
  73.     public function getUser(): ?User
  74.     {
  75.         return $this->user;
  76.     }
  77.     public function setUser(?User $user): self
  78.     {
  79.         $this->user $user;
  80.         return $this;
  81.     }
  82.     public function getPhoto(): ?Photo
  83.     {
  84.         return $this->photo;
  85.     }
  86.     public function setPhoto(?Photo $photo): self
  87.     {
  88.         $this->photo $photo;
  89.         return $this;
  90.     }
  91.     public function getInfluencer(): ?Influencer
  92.     {
  93.         return $this->influencer;
  94.     }
  95.     public function setInfluencer(?Influencer $influencer): self
  96.     {
  97.         $this->influencer $influencer;
  98.         return $this;
  99.     }
  100.     public function getComment(): ?string
  101.     {
  102.         return $this->comment;
  103.     }
  104.     public function setComment(string $comment): self
  105.     {
  106.         $this->comment $comment;
  107.         return $this;
  108.     }
  109.     public function getCreatedAt(): ?\DateTimeImmutable
  110.     {
  111.         return $this->created_at;
  112.     }
  113.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  114.     {
  115.         $this->created_at $created_at;
  116.         return $this;
  117.     }
  118.     public function getUpdatedAt(): ?\DateTimeInterface
  119.     {
  120.         return $this->updated_at;
  121.     }
  122.     public function setUpdatedAt(\DateTimeInterface $updated_at): self
  123.     {
  124.         $this->updated_at $updated_at;
  125.         return $this;
  126.     }
  127.     public function getVideo(): ?Video
  128.     {
  129.         return $this->video;
  130.     }
  131.     public function setVideo(?Video $video): self
  132.     {
  133.         $this->video $video;
  134.         return $this;
  135.     }
  136.     public function getToUser(): ?User
  137.     {
  138.         return $this->to_user;
  139.     }
  140.     public function setToUser(?User $to_user): self
  141.     {
  142.         $this->to_user $to_user;
  143.         return $this;
  144.     }
  145. }