src/Entity/Suburb.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SuburbRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=SuburbRepository::class)
  9.  */
  10. class Suburb
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\ManyToMany(targetEntity=Section::class, mappedBy="suburbs")
  24.      */
  25.     private $sections;
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=Person::class, mappedBy="subUrb")
  28.      */
  29.     private $people;
  30.     public function __construct()
  31.     {
  32.         $this->sections = new ArrayCollection();
  33.         $this->people = new ArrayCollection();
  34.     }
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function getName(): ?string
  40.     {
  41.         return $this->name;
  42.     }
  43.     public function setName(string $name): self
  44.     {
  45.         $this->name $name;
  46.         return $this;
  47.     }
  48.     /**
  49.      * @return Collection<int, Section>
  50.      */
  51.     public function getSections(): Collection
  52.     {
  53.         return $this->sections;
  54.     }
  55.     public function addSection(Section $section): self
  56.     {
  57.         if (!$this->sections->contains($section)) {
  58.             $this->sections[] = $section;
  59.             $section->addSuburb($this);
  60.         }
  61.         return $this;
  62.     }
  63.     public function removeSection(Section $section): self
  64.     {
  65.         if ($this->sections->removeElement($section)) {
  66.             // set the owning side to null (unless already changed)
  67.             if ($section->getSuburbs()->contains($this)) {
  68.                 $section->getSuburbs()->remove($this);
  69.                 $this->removeSection($section);
  70.             }
  71.         }
  72.         return $this;
  73.     }
  74.     /**
  75.      * @return Collection<int, Person>
  76.      */
  77.     public function getPeople(): Collection
  78.     {
  79.         return $this->people;
  80.     }
  81.     public function addPerson(Person $person): self
  82.     {
  83.         if (!$this->people->contains($person)) {
  84.             $this->people[] = $person;
  85.             $person->setSubUrb($this);
  86.         }
  87.         return $this;
  88.     }
  89.     public function removePerson(Person $person): self
  90.     {
  91.         if ($this->people->removeElement($person)) {
  92.             // set the owning side to null (unless already changed)
  93.             if ($person->getSubUrb() === $this) {
  94.                 $person->setSubUrb(null);
  95.             }
  96.         }
  97.         return $this;
  98.     }
  99. }