81 lines
1.6 KiB
PHP
81 lines
1.6 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Entity;
|
||
|
|
||
|
use App\Repository\DonCatRepository;
|
||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||
|
use Doctrine\Common\Collections\Collection;
|
||
|
use Doctrine\ORM\Mapping as ORM;
|
||
|
|
||
|
#[ORM\Entity(repositoryClass: DonCatRepository::class)]
|
||
|
class DonCat
|
||
|
{
|
||
|
#[ORM\Id]
|
||
|
#[ORM\GeneratedValue]
|
||
|
#[ORM\Column]
|
||
|
private ?int $id = null;
|
||
|
|
||
|
#[ORM\Column(length: 255)]
|
||
|
private ?string $name = null;
|
||
|
|
||
|
#[ORM\OneToMany(mappedBy: 'donCat', targetEntity: Don::class, orphanRemoval: true)]
|
||
|
private Collection $dons;
|
||
|
|
||
|
public function __construct()
|
||
|
{
|
||
|
$this->dons = new ArrayCollection();
|
||
|
}
|
||
|
|
||
|
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, Don>
|
||
|
*/
|
||
|
public function getDons(): Collection
|
||
|
{
|
||
|
return $this->dons;
|
||
|
}
|
||
|
|
||
|
public function addDon(Don $don): self
|
||
|
{
|
||
|
if (!$this->dons->contains($don)) {
|
||
|
$this->dons->add($don);
|
||
|
$don->setDonCat($this);
|
||
|
}
|
||
|
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
public function removeDon(Don $don): self
|
||
|
{
|
||
|
if ($this->dons->removeElement($don)) {
|
||
|
// set the owning side to null (unless already changed)
|
||
|
if ($don->getDonCat() === $this) {
|
||
|
$don->setDonCat(null);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
public function __toString()
|
||
|
{
|
||
|
return $this->name;
|
||
|
}
|
||
|
}
|