src/Entity/Master/Province.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Master;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Table(name="eposm_m_province")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Master\ProvinceRepository")
  10.  */
  11. class Province
  12. {    
  13.     public function __toString(){
  14.         return $this->name;
  15.     }
  16.     public function displayNameAndSign(){
  17.         return $this->name.' ('.$this->sign.')';
  18.     }
  19.     /**
  20.      * @ORM\Column(name="id", type="bigint")
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue(strategy="AUTO")
  23.      */
  24.     protected $id;
  25.     
  26.     /**
  27.      * @ORM\Column(name="name", type="string")
  28.      */
  29.     protected $name;
  30.     
  31.     /**
  32.      * @ORM\Column(name="sign", type="string")
  33.      */
  34.     protected $sign;
  35.     // ManyToOne
  36.         /**
  37.          * @ORM\ManyToOne(targetEntity="App\Entity\Master\Region", inversedBy="provinces")
  38.          * @ORM\JoinColumn(name="region_id", referencedColumnName="id")
  39.          */
  40.         private $region;
  41.     //
  42.     
  43.     // OneToMany
  44.         /**
  45.          * @ORM\OneToMany(targetEntity="App\Entity\Master\City", mappedBy="province")
  46.          */
  47.         private $cities;
  48.     //
  49.     public function __construct()
  50.     {
  51.         $this->cities = new ArrayCollection();
  52.     }
  53.     public function getId(): ?string
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getName(): ?string
  58.     {
  59.         return $this->name;
  60.     }
  61.     public function setName(string $name): self
  62.     {
  63.         $this->name $name;
  64.         return $this;
  65.     }
  66.     public function getSign(): ?string
  67.     {
  68.         return $this->sign;
  69.     }
  70.     public function setSign(string $sign): self
  71.     {
  72.         $this->sign $sign;
  73.         return $this;
  74.     }
  75.     public function getRegion(): ?Region
  76.     {
  77.         return $this->region;
  78.     }
  79.     public function setRegion(?Region $region): self
  80.     {
  81.         $this->region $region;
  82.         return $this;
  83.     }
  84.     /**
  85.      * @return Collection<int, City>
  86.      */
  87.     public function getCities(): Collection
  88.     {
  89.         return $this->cities;
  90.     }
  91.     public function addCity(City $city): self
  92.     {
  93.         if (!$this->cities->contains($city)) {
  94.             $this->cities->add($city);
  95.             $city->setProvince($this);
  96.         }
  97.         return $this;
  98.     }
  99.     public function removeCity(City $city): self
  100.     {
  101.         if ($this->cities->removeElement($city)) {
  102.             // set the owning side to null (unless already changed)
  103.             if ($city->getProvince() === $this) {
  104.                 $city->setProvince(null);
  105.             }
  106.         }
  107.         return $this;
  108.     }
  109. }