You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.6 KiB

<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
#[Entity]
class Village extends Thing
{
/** @var Dojo[] */
#[OneToMany(targetEntity: Dojo::class, mappedBy: 'village')]
#[JoinColumn(onDelete: 'cascade', nullable: false)]
public iterable $dojos;
#[ManyToOne()]
#[JoinColumn(onDelete: 'cascade', nullable: false)]
public Prefecture $prefecture;
public function __construct()
{
$this->dojos = new ArrayCollection();
}
/**
* @return Collection<int, Dojo>
*/
public function getDojos(): Collection
{
return $this->dojos;
}
public function addDojo(Dojo $dojo): static
{
if (!$this->dojos->contains($dojo)) {
$this->dojos->add($dojo);
$dojo->setVillage($this);
}
return $this;
}
public function removeDojo(Dojo $dojo): static
{
if ($this->dojos->removeElement($dojo)) {
// set the owning side to null (unless already changed)
if ($dojo->getVillage() === $this) {
$dojo->setVillage(null);
}
}
return $this;
}
public function getPrefecture(): ?Prefecture
{
return $this->prefecture;
}
public function setPrefecture(?Prefecture $prefecture): static
{
$this->prefecture = $prefecture;
return $this;
}
}