src/Entity/Section.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SectionRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=SectionRepository::class)
  9.  */
  10. class Section
  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 $number;
  22.     /**
  23.      * @ORM\OneToMany(targetEntity=Person::class, mappedBy="section")
  24.      */
  25.     private $persons;
  26.     /**
  27.      * @ORM\ManyToMany(targetEntity=Suburb::class, inversedBy="sections")
  28.      */
  29.     private $suburbs;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity=Route::class, inversedBy="sections")
  32.      */
  33.     private $route;
  34.     public function __construct()
  35.     {
  36.         $this->persons = new ArrayCollection();
  37.         $this->suburbs = new ArrayCollection();
  38.     }
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getNumber(): ?string
  44.     {
  45.         return $this->number;
  46.     }
  47.     public function setNumber(string $number): self
  48.     {
  49.         $this->number $number;
  50.         return $this;
  51.     }
  52.     /**
  53.      * @return Collection<int, Person>
  54.      */
  55.     public function getPersons(): Collection
  56.     {
  57.         return $this->persons;
  58.     }
  59.     public function addPerson(Person $person): self
  60.     {
  61.         if (!$this->persons->contains($person)) {
  62.             $this->persons[] = $person;
  63.             $person->setSection($this);
  64.         }
  65.         return $this;
  66.     }
  67.     public function removePerson(Person $person): self
  68.     {
  69.         if ($this->persons->removeElement($person)) {
  70.             // set the owning side to null (unless already changed)
  71.             if ($person->getSection() === $this) {
  72.                 $person->setSection(null);
  73.             }
  74.         }
  75.         return $this;
  76.     }
  77.     /**
  78.      * @return Collection<int, Suburb>
  79.      */
  80.     public function getSuburbs(): Collection
  81.     {
  82.         return $this->suburbs;
  83.     }
  84.     public function addSuburb(Suburb $suburb): self
  85.     {
  86.         if (!$this->suburbs->contains($suburb)) {
  87.             $this->suburbs[] = $suburb;
  88.         }
  89.         return $this;
  90.     }
  91.     public function removeSuburb(Suburb $suburb): self
  92.     {
  93.         $this->suburbs->removeElement($suburb);
  94.         return $this;
  95.     }
  96.     public function getRoute(): ?Route
  97.     {
  98.         return $this->route;
  99.     }
  100.     public function setRoute(?Route $route): self
  101.     {
  102.         $this->route $route;
  103.         return $this;
  104.     }
  105. }