<?phpnamespace App\Entity;use App\Repository\BoissonRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=BoissonRepository::class) */class Boisson{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $type; /** * @ORM\OneToMany(targetEntity=Cuvee::class, mappedBy="type_boisson") */ private $cuvees; /** * @ORM\ManyToOne(targetEntity=Boisson::class, inversedBy="sous_categories") */ private $parent; /** * @ORM\OneToMany(targetEntity=Boisson::class, mappedBy="parent") */ private $sous_categories; public function __construct() { $this->cuvees = new ArrayCollection(); $this->sous_categories = new ArrayCollection(); } public function __toString() { return $this->type; } public function getId(): ?int { return $this->id; } public function getType(): ?string { return $this->type; } public function setType(string $type): self { $this->type = $type; return $this; } /** * @return Collection<int, Cuvee> */ public function getCuvees(): Collection { return $this->cuvees; } public function addCuvee(Cuvee $cuvee): self { if (!$this->cuvees->contains($cuvee)) { $this->cuvees[] = $cuvee; $cuvee->setTypeBoisson($this); } return $this; } public function removeCuvee(Cuvee $cuvee): self { if ($this->cuvees->removeElement($cuvee)) { // set the owning side to null (unless already changed) if ($cuvee->getTypeBoisson() === $this) { $cuvee->setTypeBoisson(null); } } return $this; } public function getParent(): ?self { return $this->parent; } public function setParent(?self $parent): self { $this->parent = $parent; return $this; } /** * @return Collection<int, self> */ public function getSousCategories(): Collection { return $this->sous_categories; } public function addSousCategory(self $sousCategory): self { if (!$this->sous_categories->contains($sousCategory)) { $this->sous_categories[] = $sousCategory; $sousCategory->setParent($this); } return $this; } public function removeSousCategory(self $sousCategory): self { if ($this->sous_categories->removeElement($sousCategory)) { // set the owning side to null (unless already changed) if ($sousCategory->getParent() === $this) { $sousCategory->setParent(null); } } return $this; }}