<?php
namespace App\Entity;
use App\Repository\CategorieRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CategorieRepository::class)]
class Categorie
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $naam = null;
#[ORM\OneToMany(mappedBy: 'categorie', targetEntity: Onderdeel::class)]
private Collection $onderdeels;
public function __construct()
{
$this->onderdeels = new ArrayCollection();
}
public function __toString()
{
return $this->naam;
}
public function getId(): ?int
{
return $this->id;
}
public function getNaam(): ?string
{
return $this->naam;
}
public function setNaam(string $naam): static
{
$this->naam = $naam;
return $this;
}
/**
* @return Collection<int, Onderdeel>
*/
public function getOnderdeels(): Collection
{
return $this->onderdeels;
}
public function addOnderdeel(Onderdeel $onderdeel): static
{
if (!$this->onderdeels->contains($onderdeel)) {
$this->onderdeels->add($onderdeel);
$onderdeel->setCategorie($this);
}
return $this;
}
public function removeOnderdeel(Onderdeel $onderdeel): static
{
if ($this->onderdeels->removeElement($onderdeel)) {
// set the owning side to null (unless already changed)
if ($onderdeel->getCategorie() === $this) {
$onderdeel->setCategorie(null);
}
}
return $this;
}
}