src/Entity/Hero.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\HeroRepository;
  4. use App\Repository\ParkingRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
  9. #[ORM\Entity(repositoryClassHeroRepository::class)]
  10. #[HasLifecycleCallbacks]
  11. class Hero
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $hero_name null;
  19.     #[ORM\Column(length255nullabletrue)]
  20.     private ?string $hero_description null;
  21.     #[ORM\Column(length50nullabletrue)]
  22.     private ?string $hero_filename null;
  23.     #[ORM\Column]
  24.     private ?\DateTimeImmutable $createdAt null;
  25.     #[ORM\Column]
  26.     private ?\DateTimeImmutable $updatedAt null;
  27.     #[ORM\ManyToMany(targetEntityComment::class, mappedBy'comment_to_hero')]
  28.     private Collection $all_comments;
  29.     public function __construct()
  30.     {
  31.         $this->all_comments = new ArrayCollection();
  32.     }
  33.     public function __toString()
  34.     {
  35.         return $this->hero_name;
  36.     }
  37.     public function getCreatedAt(): ?\DateTimeImmutable
  38.     {
  39.         return $this->createdAt;
  40.     }
  41.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  42.     {
  43.         $this->createdAt $createdAt;
  44.         return $this;
  45.     }
  46.     public function getUpdatedAt(): ?\DateTimeImmutable
  47.     {
  48.         return $this->updatedAt;
  49.     }
  50.     public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
  51.     {
  52.         $this->updatedAt $updatedAt;
  53.         return $this;
  54.     }
  55.     #[ORM\PrePersist]
  56.     public function setCreatedAtValue(): void
  57.     {
  58.         $this->createdAt = new \DateTimeImmutable();
  59.         $this->setUpdatedAtValue();
  60.     }
  61.     #[ORM\PreUpdate]
  62.     public function setUpdatedAtValue(): void
  63.     {
  64.         $this->updatedAt = new \DateTimeImmutable();
  65.     }
  66.     public function getId(): ?int
  67.     {
  68.         return $this->id;
  69.     }
  70.     public function getHeroName(): ?string
  71.     {
  72.         return $this->hero_name;
  73.     }
  74.     public function setHeroName(string $hero_name): static
  75.     {
  76.         $this->hero_name $hero_name;
  77.         return $this;
  78.     }
  79.     public function getHeroDescription(): ?string
  80.     {
  81.         return $this->hero_description;
  82.     }
  83.     public function setHeroDescription(?string $hero_description): static
  84.     {
  85.         $this->hero_description $hero_description;
  86.         return $this;
  87.     }
  88.     
  89.     public function getHeroFilename(): ?string
  90.     {
  91.         return $this->hero_filename;
  92.     }
  93.     public function setHeroFilename(?string $hero_filename): static
  94.     {
  95.         $this->hero_filename $hero_filename;
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return Collection<int, Comment>
  100.      */
  101.     public function getAllComments(): Collection
  102.     {
  103.         return $this->all_comments;
  104.     }
  105.     public function addAllComment(Comment $allComment): static
  106.     {
  107.         if (!$this->all_comments->contains($allComment)) {
  108.             $this->all_comments->add($allComment);
  109.             $allComment->addCommentToHero($this);
  110.         }
  111.         return $this;
  112.     }
  113.     public function removeAllComment(Comment $allComment): static
  114.     {
  115.         if ($this->all_comments->removeElement($allComment)) {
  116.             $allComment->removeCommentToHero($this);
  117.         }
  118.         return $this;
  119.     }
  120. }