src/Entity/Province.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProvinceRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=ProvinceRepository::class)
  9.  */
  10. class Province
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=75, nullable=true)
  20.      */
  21.     private $nom;
  22.     /**
  23.      * @ORM\OneToMany(targetEntity=Federation::class, mappedBy="province")
  24.      */
  25.     private $federations;
  26.     /**
  27.      * @ORM\Column(type="string", length=155, nullable=true)
  28.      */
  29.     private $president;
  30.     /**
  31.      * @ORM\OneToOne(targetEntity=User::class, cascade={"persist", "remove"})
  32.      */
  33.     private $user;
  34.     /**
  35.      * @ORM\OneToMany(targetEntity=Commune::class, mappedBy="province", orphanRemoval=true)
  36.      */
  37.     private $communes;
  38.     /**
  39.      * @ORM\OneToMany(targetEntity=District::class, mappedBy="province")
  40.      */
  41.     private $districts;
  42.     public function __construct()
  43.     {
  44.         $this->federations = new ArrayCollection();
  45.         $this->communes = new ArrayCollection();
  46.         $this->districts = new ArrayCollection();
  47.     }
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getNom(): ?string
  53.     {
  54.         return $this->nom;
  55.     }
  56.     public function setNom(?string $nom): self
  57.     {
  58.         $this->nom $nom;
  59.         return $this;
  60.     }
  61.     /**
  62.      * @return Collection<int, Federation>
  63.      */
  64.     public function getFederations(): Collection
  65.     {
  66.         return $this->federations;
  67.     }
  68.     public function addFederation(Federation $federation): self
  69.     {
  70.         if (!$this->federations->contains($federation)) {
  71.             $this->federations[] = $federation;
  72.             $federation->setProvince($this);
  73.         }
  74.         return $this;
  75.     }
  76.     public function removeFederation(Federation $federation): self
  77.     {
  78.         if ($this->federations->removeElement($federation)) {
  79.             // set the owning side to null (unless already changed)
  80.             if ($federation->getProvince() === $this) {
  81.                 $federation->setProvince(null);
  82.             }
  83.         }
  84.         return $this;
  85.     }
  86.     public function getPresident(): ?string
  87.     {
  88.         return $this->president;
  89.     }
  90.     public function setPresident(?string $president): self
  91.     {
  92.         $this->president $president;
  93.         return $this;
  94.     }
  95.     public function getUser(): ?User
  96.     {
  97.         return $this->user;
  98.     }
  99.     public function setUser(?User $user): self
  100.     {
  101.         $this->user $user;
  102.         return $this;
  103.     }
  104.     /**
  105.      * @return Collection<int, Commune>
  106.      */
  107.     public function getCommunes(): Collection
  108.     {
  109.         return $this->communes;
  110.     }
  111.     public function addCommune(Commune $commune): self
  112.     {
  113.         if (!$this->communes->contains($commune)) {
  114.             $this->communes[] = $commune;
  115.             $commune->setProvince($this);
  116.         }
  117.         return $this;
  118.     }
  119.     public function removeCommune(Commune $commune): self
  120.     {
  121.         if ($this->communes->removeElement($commune)) {
  122.             // set the owning side to null (unless already changed)
  123.             if ($commune->getProvince() === $this) {
  124.                 $commune->setProvince(null);
  125.             }
  126.         }
  127.         return $this;
  128.     }
  129.     /**
  130.      * @return Collection<int, District>
  131.      */
  132.     public function getDistricts(): Collection
  133.     {
  134.         return $this->districts;
  135.     }
  136.     public function addDistrict(District $district): self
  137.     {
  138.         if (!$this->districts->contains($district)) {
  139.             $this->districts[] = $district;
  140.             $district->setProvince($this);
  141.         }
  142.         return $this;
  143.     }
  144.     public function removeDistrict(District $district): self
  145.     {
  146.         if ($this->districts->removeElement($district)) {
  147.             // set the owning side to null (unless already changed)
  148.             if ($district->getProvince() === $this) {
  149.                 $district->setProvince(null);
  150.             }
  151.         }
  152.         return $this;
  153.     }
  154. }