src/Entity/Ville.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\VilleRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=VilleRepository::class)
  9.  */
  10. class Ville
  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\OneToMany(targetEntity=User::class, mappedBy="ville")
  24.      */
  25.     private $users;
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=Quartier::class, mappedBy="ville")
  28.      * @ORM\OrderBy({"name" = "ASC"})
  29.      */
  30.     private $quartiers;
  31.     /**
  32.      * @ORM\ManyToOne(targetEntity=Pays::class, inversedBy="villes")
  33.      */
  34.     private $pays;
  35.     /**
  36.      * @ORM\Column(type="integer", nullable=true)
  37.      */
  38.     private $distancearrodissement;
  39.     /**
  40.      * @ORM\Column(type="integer", nullable=true)
  41.      */
  42.     private $distanceannulation;
  43.     /**
  44.      * @ORM\OneToMany(targetEntity=LivraisonVille::class, mappedBy="ville")
  45.      */
  46.     private $livraisonVilles;
  47.     /**
  48.      * @ORM\OneToMany(targetEntity=Zone::class, mappedBy="ville")
  49.      */
  50.     private $zones;
  51.     public function __construct()
  52.     {
  53.         $this->users = new ArrayCollection();
  54.         $this->quartiers = new ArrayCollection();
  55.         $this->livraisonVilles = new ArrayCollection();
  56.         $this->zones = new ArrayCollection();
  57.     }
  58.     public function __toString(){
  59.         return $this->getName();
  60.     }
  61.     
  62.     public function getId(): ?int
  63.     {
  64.         return $this->id;
  65.     }
  66.     public function getName(): ?string
  67.     {
  68.         return $this->name;
  69.     }
  70.     public function setName(string $name): self
  71.     {
  72.         $this->name $name;
  73.         return $this;
  74.     }
  75.     /**
  76.      * @return Collection<int, User>
  77.      */
  78.     public function getUsers(): Collection
  79.     {
  80.         return $this->users;
  81.     }
  82.     public function addUser(User $user): self
  83.     {
  84.         if (!$this->users->contains($user)) {
  85.             $this->users[] = $user;
  86.             $user->setVille($this);
  87.         }
  88.         return $this;
  89.     }
  90.     public function removeUser(User $user): self
  91.     {
  92.         if ($this->users->removeElement($user)) {
  93.             // set the owning side to null (unless already changed)
  94.             if ($user->getVille() === $this) {
  95.                 $user->setVille(null);
  96.             }
  97.         }
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return Collection<int, Quartier>
  102.      */
  103.     public function getQuartiers(): Collection
  104.     {
  105.         return $this->quartiers;
  106.     }
  107.     public function addQuartier(Quartier $quartier): self
  108.     {
  109.         if (!$this->quartiers->contains($quartier)) {
  110.             $this->quartiers[] = $quartier;
  111.             $quartier->setVille($this);
  112.         }
  113.         return $this;
  114.     }
  115.     public function removeQuartier(Quartier $quartier): self
  116.     {
  117.         if ($this->quartiers->removeElement($quartier)) {
  118.             // set the owning side to null (unless already changed)
  119.             if ($quartier->getVille() === $this) {
  120.                 $quartier->setVille(null);
  121.             }
  122.         }
  123.         return $this;
  124.     }
  125.     public function getPays(): ?Pays
  126.     {
  127.         return $this->pays;
  128.     }
  129.     public function setPays(?Pays $pays): self
  130.     {
  131.         $this->pays $pays;
  132.         return $this;
  133.     }
  134.     public function getDistancearrodissement(): ?int
  135.     {
  136.         return $this->distancearrodissement;
  137.     }
  138.     public function setDistancearrodissement(?int $distancearrodissement): self
  139.     {
  140.         $this->distancearrodissement $distancearrodissement;
  141.         return $this;
  142.     }
  143.     public function getDistanceannulation(): ?int
  144.     {
  145.         return $this->distanceannulation;
  146.     }
  147.     public function setDistanceannulation(?int $distanceannulation): self
  148.     {
  149.         $this->distanceannulation $distanceannulation;
  150.         return $this;
  151.     }
  152.     /**
  153.      * @return Collection<int, LivraisonVille>
  154.      */
  155.     public function getLivraisonVilles(): Collection
  156.     {
  157.         return $this->livraisonVilles;
  158.     }
  159.     public function addLivraisonVille(LivraisonVille $livraisonVille): self
  160.     {
  161.         if (!$this->livraisonVilles->contains($livraisonVille)) {
  162.             $this->livraisonVilles[] = $livraisonVille;
  163.             $livraisonVille->setVille($this);
  164.         }
  165.         return $this;
  166.     }
  167.     public function removeLivraisonVille(LivraisonVille $livraisonVille): self
  168.     {
  169.         if ($this->livraisonVilles->removeElement($livraisonVille)) {
  170.             // set the owning side to null (unless already changed)
  171.             if ($livraisonVille->getVille() === $this) {
  172.                 $livraisonVille->setVille(null);
  173.             }
  174.         }
  175.         return $this;
  176.     }
  177.     /**
  178.      * @return Collection<int, Zone>
  179.      */
  180.     public function getZones(): Collection
  181.     {
  182.         return $this->zones;
  183.     }
  184.     public function addZone(Zone $zone): self
  185.     {
  186.         if (!$this->zones->contains($zone)) {
  187.             $this->zones[] = $zone;
  188.             $zone->setVille($this);
  189.         }
  190.         return $this;
  191.     }
  192.     public function removeZone(Zone $zone): self
  193.     {
  194.         if ($this->zones->removeElement($zone)) {
  195.             // set the owning side to null (unless already changed)
  196.             if ($zone->getVille() === $this) {
  197.                 $zone->setVille(null);
  198.             }
  199.         }
  200.         return $this;
  201.     }
  202. }