src/Entity/Cantons.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClass\App\Repository\CantonsRepository::class)]
  7. class Cantons implements \Stringable
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column(type'integer')]
  12.     private int $id;
  13.     #[ORM\Column(type'string'length255nullabletrue)]
  14.     private ?string $canton"";
  15.     #[ORM\Column(type'string'length255nullabletrue)]
  16.     private ?string $territoire"";
  17.     #[ORM\Column(type'text'nullabletrue)]
  18.     private ?string $communes"";
  19.     #[ORM\OneToMany(targetEntity\App\Entity\Contact::class, mappedBy'canton')]
  20.     private mixed $contacts;
  21.     #[ORM\Column(type'text'nullabletrue)]
  22.     private ?string $multipoints"";
  23.     #[ORM\ManyToOne(targetEntity\App\Entity\Territory::class, inversedBy'cantons')]
  24.     private mixed $territory;
  25.     public function __construct()
  26.     {
  27.         $this->contacts = new ArrayCollection();
  28.     }
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function getCanton(): ?string
  34.     {
  35.         return $this->canton;
  36.     }
  37.     public function setCanton(?string $canton): self
  38.     {
  39.         $this->canton $canton;
  40.         return $this;
  41.     }
  42.     public function getTerritoire(): ?string
  43.     {
  44.         return $this->territoire;
  45.     }
  46.     public function setTerritoire(?string $territoire): self
  47.     {
  48.         $this->territoire $territoire;
  49.         return $this;
  50.     }
  51.     public function getCommunes(): ?string
  52.     {
  53.         return $this->communes;
  54.     }
  55.     public function setCommunes(?string $communes): self
  56.     {
  57.         $this->communes $communes;
  58.         return $this;
  59.     }
  60.     /**
  61.      * @return Collection|Contact[]
  62.      */
  63.     public function getContacts(): Collection
  64.     {
  65.         return $this->contacts;
  66.     }
  67.     public function addContact(Contact $contact): self
  68.     {
  69.         if (!$this->contacts->contains($contact)) {
  70.             $this->contacts[] = $contact;
  71.             $contact->setCanton($this);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeContact(Contact $contact): self
  76.     {
  77.         if ($this->contacts->contains($contact)) {
  78.             $this->contacts->removeElement($contact);
  79.             // set the owning side to null (unless already changed)
  80.             if ($contact->getCanton() === $this) {
  81.                 $contact->setCanton(null);
  82.             }
  83.         }
  84.         return $this;
  85.     }
  86.     public function __toString(): string
  87.     {
  88.         return (string) $this->canton;
  89.     }
  90.     public function getMultipoints(): ?string
  91.     {
  92.         return $this->multipoints;
  93.     }
  94.     public function setMultipoints(?string $multipoints): self
  95.     {
  96.         $this->multipoints $multipoints;
  97.         return $this;
  98.     }
  99.     public function getTerritory(): ?Territory
  100.     {
  101.         return $this->territory;
  102.     }
  103.     public function setTerritory(?Territory $territory): self
  104.     {
  105.         $this->territory $territory;
  106.         return $this;
  107.     }
  108. }