<?php
namespace App\Entity;
use App\Repository\CommentRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CommentRepository::class)]
class Comment
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $body = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $author = null;
#[ORM\ManyToMany(targetEntity: Hero::class, inversedBy: 'all_comments')]
private Collection $comment_to_hero;
#[ORM\Column(length: 100, nullable: true)]
private ?string $comment = null;
public function __construct()
{
$this->comment_to_hero = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getBody(): ?string
{
return $this->body;
}
public function setBody(?string $body): static
{
$this->body = $body;
return $this;
}
public function getAuthor(): ?string
{
return $this->author;
}
public function setAuthor(?string $author): static
{
$this->author = $author;
return $this;
}
/**
* @return Collection<int, Hero>
*/
public function getCommentToHero(): Collection
{
return $this->comment_to_hero;
}
public function addCommentToHero(Hero $commentToHero): static
{
if (!$this->comment_to_hero->contains($commentToHero)) {
$this->comment_to_hero->add($commentToHero);
}
return $this;
}
public function removeCommentToHero(Hero $commentToHero): static
{
$this->comment_to_hero->removeElement($commentToHero);
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): static
{
$this->comment = $comment;
return $this;
}
}