<?php
namespace App\Entity;
use App\Repository\ModelRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ModelRepository::class)]
class Model
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $naam = null;
#[ORM\OneToMany(mappedBy: 'model', targetEntity: Modelonderdeel::class, orphanRemoval: true)]
private Collection $modelonderdelen;
public function __construct()
{
$this->modelonderdelen = new ArrayCollection();
}
public function __toString() : string
{
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, Modelonderdeel>
*/
public function getModelonderdelen(): Collection
{
return $this->modelonderdelen;
}
public function addModelonderdelen(Modelonderdeel $modelonderdelen): static
{
if (!$this->modelonderdelen->contains($modelonderdelen)) {
$this->modelonderdelen->add($modelonderdelen);
$modelonderdelen->setModel($this);
}
return $this;
}
public function removeModelonderdelen(Modelonderdeel $modelonderdelen): static
{
if ($this->modelonderdelen->removeElement($modelonderdelen)) {
// set the owning side to null (unless already changed)
if ($modelonderdelen->getModel() === $this) {
$modelonderdelen->setModel(null);
}
}
return $this;
}
}