src/CasinoBundle/Entity/Region.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\CasinoBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * Region
  7.  *
  8.  * @ORM\Table(name="region", indexes={@ORM\Index(name="idx_region_lookup", columns={"id"})})
  9.  * @ORM\Entity(repositoryClass="App\CasinoBundle\Repository\RegionRepository")
  10.  */
  11. class Region
  12. {
  13.     /**
  14.      * @var int
  15.      *
  16.      * @ORM\Column(name="id", type="bigint", nullable=false)
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue(strategy="IDENTITY")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @var string|null
  23.      *
  24.      * @ORM\Column(name="name", type="string", length=35, nullable=true)
  25.      */
  26.     private $name;
  27.     /**
  28.      * @ORM\OneToMany(targetEntity="Country", mappedBy="region")
  29.      */
  30.     private $countries;
  31.     public function __construct()
  32.     {
  33.         $this->countries = new ArrayCollection();
  34.     }
  35.     public function __toString()
  36.     {
  37.         return $this->name;
  38.     }
  39.     /**
  40.      * @return int
  41.      */
  42.     public function getId(): int
  43.     {
  44.         return $this->id;
  45.     }
  46.     /**
  47.      * @param int $id
  48.      */
  49.     public function setId(int $id): void
  50.     {
  51.         $this->id $id;
  52.     }
  53.     /**
  54.      * @return null|string
  55.      */
  56.     public function getName(): ?string
  57.     {
  58.         return $this->name;
  59.     }
  60.     /**
  61.      * @param null|string $name
  62.      */
  63.     public function setName(?string $name): void
  64.     {
  65.         $this->name $name;
  66.     }
  67.     public function getCountries()
  68.     {
  69.         return $this->countries ?? new ArrayCollection();
  70.     }
  71.     public function addCountry(Country $country): self
  72.     {
  73.         if (!$this->countries->contains($country)) {
  74.             $this->countries[] = $country;
  75.             $country->setRegion($this);
  76.         }
  77.         return $this;
  78.     }
  79.     public function removeCountry(Country $country): self
  80.     {
  81.         if ($this->countries->contains($country)) {
  82.             $this->countries->removeElement($country);
  83.             $country->setRegion(null);
  84.         }
  85.         return $this;
  86.     }
  87. }