src/Entity/Region.php line 13

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. use Symfony\Component\Serializer\Annotation\Groups;
  7. /**
  8.  * @ORM\Entity(repositoryClass="App\Repository\RegionRepository")
  9.  */
  10. class Region
  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.      * @Groups({"searchable"})
  21.      */
  22.     private $name;
  23.     /**
  24.      * @ORM\Column(type="string", length=50)
  25.      */
  26.     private $province;
  27.     /**
  28.      * @ORM\Column(type="string", length=100)
  29.      */
  30.     private $country;
  31.     /**
  32.      * @ORM\OneToMany(targetEntity="App\Entity\Product", mappedBy="region")
  33.      */
  34.     private $products;
  35.     /**
  36.      * @ORM\OneToMany(targetEntity="App\Entity\CompanyLocation", mappedBy="region")
  37.      */
  38.     private $companyLocations;
  39.     /**
  40.      * @ORM\OneToMany(targetEntity="App\Entity\City", mappedBy="region")
  41.      */
  42.     private $cities;
  43.     public function __construct()
  44.     {
  45.         $this->products = new ArrayCollection();
  46.         $this->companyLocations = new ArrayCollection();
  47.         $this->cities = new ArrayCollection();
  48.     }
  49.     public function getId()
  50.     {
  51.         return $this->id;
  52.     }
  53.     public function getName(): ?string
  54.     {
  55.         return $this->name;
  56.     }
  57.     public function setName(string $name): self
  58.     {
  59.         $this->name $name;
  60.         return $this;
  61.     }
  62.     public function getProvince(): ?string
  63.     {
  64.         return $this->province;
  65.     }
  66.     public function setProvince(string $province): self
  67.     {
  68.         $this->province $province;
  69.         return $this;
  70.     }
  71.     public function getCountry(): ?string
  72.     {
  73.         return $this->country;
  74.     }
  75.     public function setCountry(string $country): self
  76.     {
  77.         $this->country $country;
  78.         return $this;
  79.     }
  80.     /**
  81.      * @return Collection|Product[]
  82.      */
  83.     public function getProducts(): Collection
  84.     {
  85.         return $this->products;
  86.     }
  87.     public function addProduct(Product $product): self
  88.     {
  89.         if (!$this->products->contains($product)) {
  90.             $this->products[] = $product;
  91.             $product->setRegion($this);
  92.         }
  93.         return $this;
  94.     }
  95.     public function removeProduct(Product $product): self
  96.     {
  97.         if ($this->products->contains($product)) {
  98.             $this->products->removeElement($product);
  99.             // set the owning side to null (unless already changed)
  100.             if ($product->getRegion() === $this) {
  101.                 $product->setRegion(null);
  102.             }
  103.         }
  104.         return $this;
  105.     }
  106.     /**
  107.      * @return Collection|Company[]
  108.      */
  109.     public function getCompanies(): Collection
  110.     {
  111.         return $this->companies;
  112.     }
  113.     /**
  114.      * @return Collection|CompanyLocation[]
  115.      */
  116.     public function getCompanyLocations(): Collection
  117.     {
  118.         return $this->companyLocations;
  119.     }
  120.     public function addCompanyLocation(CompanyLocation $companyLocation): self
  121.     {
  122.         if (!$this->companyLocations->contains($companyLocation)) {
  123.             $this->companyLocations[] = $companyLocation;
  124.             $companyLocation->setRegion($this);
  125.         }
  126.         return $this;
  127.     }
  128.     public function removeCompanyLocation(CompanyLocation $companyLocation): self
  129.     {
  130.         if ($this->companyLocations->contains($companyLocation)) {
  131.             $this->companyLocations->removeElement($companyLocation);
  132.             // set the owning side to null (unless already changed)
  133.             if ($companyLocation->getRegion() === $this) {
  134.                 $companyLocation->setRegion(null);
  135.             }
  136.         }
  137.         return $this;
  138.     }
  139.     /**
  140.      * @return Collection|City[]
  141.      */
  142.     public function getCities(): Collection
  143.     {
  144.         return $this->cities;
  145.     }
  146.     public function addCity(City $city): self
  147.     {
  148.         if (!$this->cities->contains($city)) {
  149.             $this->cities[] = $city;
  150.             $city->setRegion($this);
  151.         }
  152.         return $this;
  153.     }
  154.     public function removeCity(City $city): self
  155.     {
  156.         if ($this->cities->contains($city)) {
  157.             $this->cities->removeElement($city);
  158.             // set the owning side to null (unless already changed)
  159.             if ($city->getRegion() === $this) {
  160.                 $city->setRegion(null);
  161.             }
  162.         }
  163.         return $this;
  164.     }
  165.     public function __toString()
  166.     {
  167.         return $this->getName();
  168.     }
  169. }