<?php
namespace App\CasinoBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Region
*
* @ORM\Table(name="region", indexes={@ORM\Index(name="idx_region_lookup", columns={"id"})})
* @ORM\Entity(repositoryClass="App\CasinoBundle\Repository\RegionRepository")
*/
class Region
{
/**
* @var int
*
* @ORM\Column(name="id", type="bigint", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string|null
*
* @ORM\Column(name="name", type="string", length=35, nullable=true)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity="Country", mappedBy="region")
*/
private $countries;
public function __construct()
{
$this->countries = new ArrayCollection();
}
public function __toString()
{
return $this->name;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
/**
* @return null|string
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param null|string $name
*/
public function setName(?string $name): void
{
$this->name = $name;
}
public function getCountries()
{
return $this->countries ?? new ArrayCollection();
}
public function addCountry(Country $country): self
{
if (!$this->countries->contains($country)) {
$this->countries[] = $country;
$country->setRegion($this);
}
return $this;
}
public function removeCountry(Country $country): self
{
if ($this->countries->contains($country)) {
$this->countries->removeElement($country);
$country->setRegion(null);
}
return $this;
}
}