src/Entity/LocalEventTag.php line 13
<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\LocalEventTagRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: LocalEventTagRepository::class)]
#[ApiResource]
class LocalEventTag
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 65, unique: true)]
private ?string $name = null;
#[ORM\Column(length: 65, unique: true)]
private ?string $slug = null;
#[ORM\ManyToMany(targetEntity: LocalEvent::class, mappedBy: 'tags', fetch: 'EAGER')]
private Collection $localEvents;
public function __construct()
{
$this->localEvents = new ArrayCollection();
}
public function __toString(): string
{
return $this->getName();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, LocalEvent>
*/
public function getLocalEvents(): Collection
{
return $this->localEvents;
}
public function addLocalEvent(LocalEvent $localEvent): self
{
if (!$this->localEvents->contains($localEvent)) {
$this->localEvents->add($localEvent);
$localEvent->addTag($this);
}
return $this;
}
public function removeLocalEvent(LocalEvent $localEvent): self
{
if ($this->localEvents->removeElement($localEvent)) {
$localEvent->removeTag($this);
}
return $this;
}
}