<?phpnamespace App\Entity;use App\Repository\HeroRepository;use App\Repository\ParkingRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Doctrine\ORM\Mapping\HasLifecycleCallbacks;#[ORM\Entity(repositoryClass: HeroRepository::class)]#[HasLifecycleCallbacks]class Hero{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 255)] private ?string $hero_name = null; #[ORM\Column(length: 255, nullable: true)] private ?string $hero_description = null; #[ORM\Column(length: 50, nullable: true)] private ?string $hero_filename = null; #[ORM\Column] private ?\DateTimeImmutable $createdAt = null; #[ORM\Column] private ?\DateTimeImmutable $updatedAt = null; #[ORM\ManyToMany(targetEntity: Comment::class, mappedBy: 'comment_to_hero')] private Collection $all_comments; public function __construct() { $this->all_comments = new ArrayCollection(); } public function __toString() { return $this->hero_name; } public function getCreatedAt(): ?\DateTimeImmutable { return $this->createdAt; } public function setCreatedAt(\DateTimeImmutable $createdAt): self { $this->createdAt = $createdAt; return $this; } public function getUpdatedAt(): ?\DateTimeImmutable { return $this->updatedAt; } public function setUpdatedAt(\DateTimeImmutable $updatedAt): self { $this->updatedAt = $updatedAt; return $this; } #[ORM\PrePersist] public function setCreatedAtValue(): void { $this->createdAt = new \DateTimeImmutable(); $this->setUpdatedAtValue(); } #[ORM\PreUpdate] public function setUpdatedAtValue(): void { $this->updatedAt = new \DateTimeImmutable(); } public function getId(): ?int { return $this->id; } public function getHeroName(): ?string { return $this->hero_name; } public function setHeroName(string $hero_name): static { $this->hero_name = $hero_name; return $this; } public function getHeroDescription(): ?string { return $this->hero_description; } public function setHeroDescription(?string $hero_description): static { $this->hero_description = $hero_description; return $this; } public function getHeroFilename(): ?string { return $this->hero_filename; } public function setHeroFilename(?string $hero_filename): static { $this->hero_filename = $hero_filename; return $this; } /** * @return Collection<int, Comment> */ public function getAllComments(): Collection { return $this->all_comments; } public function addAllComment(Comment $allComment): static { if (!$this->all_comments->contains($allComment)) { $this->all_comments->add($allComment); $allComment->addCommentToHero($this); } return $this; } public function removeAllComment(Comment $allComment): static { if ($this->all_comments->removeElement($allComment)) { $allComment->removeCommentToHero($this); } return $this; }}