src/Entity/Comment.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CommentRepository;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass=CommentRepository::class)
  8.  */
  9. class Comment
  10. {
  11.     const LABEL=[
  12.         'Mauvais'=>'Mauvais',
  13.         'Passable'=>'Passable',
  14.         'Bien'=>'Bien',
  15.         'Très bien'=>'Très bien',
  16.     ];
  17.     public function __construct()
  18.     {
  19.         $this->created_at = new \DateTime();
  20.     }
  21.     /**
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue
  24.      * @ORM\Column(type="integer")
  25.      */
  26.     private $id;
  27.     /**
  28.      * @ORM\Column(type="text")
  29.      * @Assert\NotBlank(message="Le contenu ne peut être vide")
  30.      * @Assert\Length(
  31.      *     min = 10,
  32.      *     minMessage = "Ce titre est trop court",
  33.      * )
  34.      */
  35.     private $content;
  36.     /**
  37.      * @ORM\Column(type="datetime")
  38.      */
  39.     private $created_at;
  40.     /**
  41.      * @ORM\ManyToOne(targetEntity=Article::class, inversedBy="comments")
  42.      * @ORM\JoinColumn(nullable=false)
  43.      */
  44.     private $article;
  45.     /**
  46.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="comments")
  47.      * @ORM\JoinColumn(nullable=false)
  48.      */
  49.     private $user;
  50.     /**
  51.      * @ORM\Column(type="integer")
  52.      */
  53.     private $rating;
  54.     /**
  55.      * @ORM\Column(type="string", length=255, nullable=true)
  56.      */
  57.     private $label;
  58.     public function getId(): ?int
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getContent(): ?string
  63.     {
  64.         return $this->content;
  65.     }
  66.     public function setContent(string $content): self
  67.     {
  68.         $this->content $content;
  69.         return $this;
  70.     }
  71.     public function getCreatedAt(): ?\DateTimeInterface
  72.     {
  73.         return $this->created_at;
  74.     }
  75.     public function setCreatedAt(\DateTimeInterface $created_at): self
  76.     {
  77.         $this->created_at $created_at;
  78.         return $this;
  79.     }
  80.     public function getArticle(): ?Article
  81.     {
  82.         return $this->article;
  83.     }
  84.     public function setArticle(?Article $article): self
  85.     {
  86.         $this->article $article;
  87.         return $this;
  88.     }
  89.     public function getUser(): ?User
  90.     {
  91.         return $this->user;
  92.     }
  93.     public function setUser(?User $user): self
  94.     {
  95.         $this->user $user;
  96.         return $this;
  97.     }
  98.     public function getRating(): ?int
  99.     {
  100.         return $this->rating;
  101.     }
  102.     public function setRating(int $rating): self
  103.     {
  104.         $this->rating $rating;
  105.         return $this;
  106.     }
  107.     public function getLabel(): ?string
  108.     {
  109.         return $this->label;
  110.     }
  111.     public function setLabel(?string $label): self
  112.     {
  113.         $this->label $label;
  114.         return $this;
  115.     }
  116. }