<?php
namespace App\Entity\Gallery;
use App\Repository\Gallery\GalleryCategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: GalleryCategoryRepository::class)]
class GalleryCategory
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\ManyToMany(targetEntity: Gallery::class, inversedBy: 'galleryCategories', cascade: ['persist'])]
private Collection $Gallery;
public function __construct()
{
$this->Gallery = new ArrayCollection();
}
public function __toString()
{
return $this->name;
}
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;
}
/**
* @return Collection<int, Gallery>
*/
public function getGallery(): Collection
{
return $this->Gallery;
}
public function addGallery(Gallery $gallery): self
{
if (!$this->Gallery->contains($gallery)) {
$this->Gallery->add($gallery);
}
return $this;
}
public function removeGallery(Gallery $gallery): self
{
$this->Gallery->removeElement($gallery);
return $this;
}
}