src/Entity/LocalEventTag.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\LocalEventTagRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassLocalEventTagRepository::class)]
  9. #[ApiResource]
  10. class LocalEventTag
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length65uniquetrue)]
  17.     private ?string $name null;
  18.     #[ORM\Column(length65uniquetrue)]
  19.     private ?string $slug null;
  20.     #[ORM\ManyToMany(targetEntityLocalEvent::class, mappedBy'tags'fetch'EAGER')]
  21.     private Collection $localEvents;
  22.     public function __construct()
  23.     {
  24.         $this->localEvents = new ArrayCollection();
  25.     }
  26.     public function __toString(): string
  27.     {
  28.         return $this->getName();
  29.     }
  30.     public function getId(): ?int
  31.     {
  32.         return $this->id;
  33.     }
  34.     public function getName(): ?string
  35.     {
  36.         return $this->name;
  37.     }
  38.     public function setName(string $name): self
  39.     {
  40.         $this->name $name;
  41.         return $this;
  42.     }
  43.     public function getSlug(): ?string
  44.     {
  45.         return $this->slug;
  46.     }
  47.     public function setSlug(string $slug): self
  48.     {
  49.         $this->slug $slug;
  50.         return $this;
  51.     }
  52.     /**
  53.      * @return Collection<int, LocalEvent>
  54.      */
  55.     public function getLocalEvents(): Collection
  56.     {
  57.         return $this->localEvents;
  58.     }
  59.     public function addLocalEvent(LocalEvent $localEvent): self
  60.     {
  61.         if (!$this->localEvents->contains($localEvent)) {
  62.             $this->localEvents->add($localEvent);
  63.             $localEvent->addTag($this);
  64.         }
  65.         return $this;
  66.     }
  67.     public function removeLocalEvent(LocalEvent $localEvent): self
  68.     {
  69.         if ($this->localEvents->removeElement($localEvent)) {
  70.             $localEvent->removeTag($this);
  71.         }
  72.         return $this;
  73.     }
  74. }