src/CasinoBundle/Entity/State.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\CasinoBundle\Entity;
  3. use App\CmsBundle\Entity\PublishedTrait;
  4. use App\CmsBundle\Entity\SlugTrait;
  5. use App\CmsBundle\Entity\TimeStampedTrait;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. /**
  10.  * State
  11.  *
  12.  * @ORM\Table(
  13.  *     name="state",
  14.  *     uniqueConstraints={
  15.  *          @ORM\UniqueConstraint(name="state_slug_uindex", columns={"slug"}),
  16.  *          @ORM\UniqueConstraint(name="state_alpha2_uindex", columns={"alpha2"})
  17.  *     },
  18.  *     indexes={
  19.  *          @ORM\Index(name="state_published_index", columns={"published"})
  20.  *     }
  21.  * )
  22.  * @ORM\Entity(repositoryClass="App\CasinoBundle\Repository\StateRepository")
  23.  * @ORM\HasLifecycleCallbacks()
  24.  */
  25. class State
  26. {
  27.     use SlugTrait;
  28.     use AliasTrait;
  29.     use PublishedTrait;
  30.     use TimeStampedTrait;
  31.     /**
  32.      * @var int
  33.      *
  34.      * @ORM\Column(name="id", type="bigint", nullable=false)
  35.      * @ORM\Id
  36.      * @ORM\GeneratedValue(strategy="IDENTITY")
  37.      */
  38.     private $id;
  39.     /**
  40.      * @var string|null
  41.      *
  42.      * @ORM\Column(name="name", type="string", length=35, nullable=true)
  43.      */
  44.     private $name;
  45.     /**
  46.      * @var Country|null
  47.      * @ORM\ManyToOne(targetEntity="Country", inversedBy="states")
  48.      * @ORM\JoinColumn(name="country_id", referencedColumnName="id")
  49.      */
  50.     private $country;
  51.     /**
  52.      * @ORM\OneToMany(targetEntity="City", mappedBy="state")
  53.      */
  54.     private $cities;
  55.     /**
  56.      * @var string|null
  57.      *
  58.      * @ORM\Column(name="alpha2", type="string", length=2, nullable=true)
  59.      */
  60.     private ?string $alpha2;
  61.     /**
  62.      * @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Alias", mappedBy="state", cascade={"persist"}, orphanRemoval=true)
  63.      */
  64.     private Collection $aliases;
  65.     public function __construct()
  66.     {
  67.         $this->cities = new ArrayCollection();
  68.         $this->aliases = new ArrayCollection();
  69.     }
  70.     public function __toString()
  71.     {
  72.         return $this->name;
  73.     }
  74.     /**
  75.      * @return int
  76.      */
  77.     public function getId(): int
  78.     {
  79.         return $this->id;
  80.     }
  81.     /**
  82.      * @param int $id
  83.      */
  84.     public function setId(int $id): void
  85.     {
  86.         $this->id $id;
  87.     }
  88.     /**
  89.      * @return null|string
  90.      */
  91.     public function getName(): ?string
  92.     {
  93.         return $this->name;
  94.     }
  95.     /**
  96.      * @param null|string $name
  97.      */
  98.     public function setName(?string $name): void
  99.     {
  100.         $this->name $name;
  101.     }
  102.     /**
  103.      * @return Country
  104.      */
  105.     public function getCountry(): ?Country
  106.     {
  107.         return $this->country;
  108.     }
  109.     /**
  110.      * @param Country $country
  111.      * @return City
  112.      */
  113.     public function setCountry(Country $country): self
  114.     {
  115.         $this->country $country;
  116.         return $this;
  117.     }
  118.     /**
  119.      * @return mixed
  120.      */
  121.     public function getCities()
  122.     {
  123.         return $this->cities;
  124.     }
  125.     /**
  126.      * @return string|null
  127.      */
  128.     public function getAlpha2(): ?string
  129.     {
  130.         return $this->alpha2;
  131.     }
  132.     /**
  133.      * @param string $alpha2
  134.      * @return $this
  135.      */
  136.     public function setAlpha2(string $alpha2): self
  137.     {
  138.         $this->alpha2 $alpha2;
  139.         return $this;
  140.     }
  141. }