<?php
namespace App\Entity\Master;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="eposm_m_province")
* @ORM\Entity(repositoryClass="App\Repository\Master\ProvinceRepository")
*/
class Province
{
public function __toString(){
return $this->name;
}
public function displayNameAndSign(){
return $this->name.' ('.$this->sign.')';
}
/**
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="name", type="string")
*/
protected $name;
/**
* @ORM\Column(name="sign", type="string")
*/
protected $sign;
// ManyToOne
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Master\Region", inversedBy="provinces")
* @ORM\JoinColumn(name="region_id", referencedColumnName="id")
*/
private $region;
//
// OneToMany
/**
* @ORM\OneToMany(targetEntity="App\Entity\Master\City", mappedBy="province")
*/
private $cities;
//
public function __construct()
{
$this->cities = new ArrayCollection();
}
public function getId(): ?string
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSign(): ?string
{
return $this->sign;
}
public function setSign(string $sign): self
{
$this->sign = $sign;
return $this;
}
public function getRegion(): ?Region
{
return $this->region;
}
public function setRegion(?Region $region): self
{
$this->region = $region;
return $this;
}
/**
* @return Collection<int, City>
*/
public function getCities(): Collection
{
return $this->cities;
}
public function addCity(City $city): self
{
if (!$this->cities->contains($city)) {
$this->cities->add($city);
$city->setProvince($this);
}
return $this;
}
public function removeCity(City $city): self
{
if ($this->cities->removeElement($city)) {
// set the owning side to null (unless already changed)
if ($city->getProvince() === $this) {
$city->setProvince(null);
}
}
return $this;
}
}