<?phpnamespace App\Entity;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;/** * @ORM\Entity(repositoryClass="App\Repository\RegionRepository") */class Region{ /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) * @Groups({"searchable"}) */ private $name; /** * @ORM\Column(type="string", length=50) */ private $province; /** * @ORM\Column(type="string", length=100) */ private $country; /** * @ORM\OneToMany(targetEntity="App\Entity\Product", mappedBy="region") */ private $products; /** * @ORM\OneToMany(targetEntity="App\Entity\CompanyLocation", mappedBy="region") */ private $companyLocations; /** * @ORM\OneToMany(targetEntity="App\Entity\City", mappedBy="region") */ private $cities; public function __construct() { $this->products = new ArrayCollection(); $this->companyLocations = new ArrayCollection(); $this->cities = new ArrayCollection(); } public function getId() { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getProvince(): ?string { return $this->province; } public function setProvince(string $province): self { $this->province = $province; return $this; } public function getCountry(): ?string { return $this->country; } public function setCountry(string $country): self { $this->country = $country; return $this; } /** * @return Collection|Product[] */ public function getProducts(): Collection { return $this->products; } public function addProduct(Product $product): self { if (!$this->products->contains($product)) { $this->products[] = $product; $product->setRegion($this); } return $this; } public function removeProduct(Product $product): self { if ($this->products->contains($product)) { $this->products->removeElement($product); // set the owning side to null (unless already changed) if ($product->getRegion() === $this) { $product->setRegion(null); } } return $this; } /** * @return Collection|Company[] */ public function getCompanies(): Collection { return $this->companies; } /** * @return Collection|CompanyLocation[] */ public function getCompanyLocations(): Collection { return $this->companyLocations; } public function addCompanyLocation(CompanyLocation $companyLocation): self { if (!$this->companyLocations->contains($companyLocation)) { $this->companyLocations[] = $companyLocation; $companyLocation->setRegion($this); } return $this; } public function removeCompanyLocation(CompanyLocation $companyLocation): self { if ($this->companyLocations->contains($companyLocation)) { $this->companyLocations->removeElement($companyLocation); // set the owning side to null (unless already changed) if ($companyLocation->getRegion() === $this) { $companyLocation->setRegion(null); } } return $this; } /** * @return Collection|City[] */ public function getCities(): Collection { return $this->cities; } public function addCity(City $city): self { if (!$this->cities->contains($city)) { $this->cities[] = $city; $city->setRegion($this); } return $this; } public function removeCity(City $city): self { if ($this->cities->contains($city)) { $this->cities->removeElement($city); // set the owning side to null (unless already changed) if ($city->getRegion() === $this) { $city->setRegion(null); } } return $this; } public function __toString() { return $this->getName(); }}