src/Entity/Comment.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CommentRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassCommentRepository::class)]
  9. class Comment
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  16.     private ?string $body null;
  17.     #[ORM\Column(length255nullabletrue)]
  18.     private ?string $author null;
  19.     #[ORM\ManyToMany(targetEntityHero::class, inversedBy'all_comments')]
  20.     private Collection $comment_to_hero;
  21.     #[ORM\Column(length100nullabletrue)]
  22.     private ?string $comment null;
  23.     public function __construct()
  24.     {
  25.         $this->comment_to_hero = new ArrayCollection();
  26.     }
  27.     public function getId(): ?int
  28.     {
  29.         return $this->id;
  30.     }
  31.     public function getBody(): ?string
  32.     {
  33.         return $this->body;
  34.     }
  35.     public function setBody(?string $body): static
  36.     {
  37.         $this->body $body;
  38.         return $this;
  39.     }
  40.     public function getAuthor(): ?string
  41.     {
  42.         return $this->author;
  43.     }
  44.     public function setAuthor(?string $author): static
  45.     {
  46.         $this->author $author;
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection<int, Hero>
  51.      */
  52.     public function getCommentToHero(): Collection
  53.     {
  54.         return $this->comment_to_hero;
  55.     }
  56.     public function addCommentToHero(Hero $commentToHero): static
  57.     {
  58.         if (!$this->comment_to_hero->contains($commentToHero)) {
  59.             $this->comment_to_hero->add($commentToHero);
  60.         }
  61.         return $this;
  62.     }
  63.     public function removeCommentToHero(Hero $commentToHero): static
  64.     {
  65.         $this->comment_to_hero->removeElement($commentToHero);
  66.         return $this;
  67.     }
  68.     public function getComment(): ?string
  69.     {
  70.         return $this->comment;
  71.     }
  72.     public function setComment(?string $comment): static
  73.     {
  74.         $this->comment $comment;
  75.         return $this;
  76.     }
  77. }