src/CasinoBundle/Entity/Keyword.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\CasinoBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * Game
  8.  *
  9.  * @ORM\Table(name="keyword")
  10.  * @ORM\Entity(repositoryClass="App\CasinoBundle\Repository\KeywordRepository")
  11.  */
  12. class Keyword
  13. {
  14.     /**
  15.      * @var int
  16.      *
  17.      * @ORM\Column(name="id", type="integer", nullable=false)
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue()
  20.      */
  21.     private $id;
  22.     /**
  23.      * @var string
  24.      *
  25.      * @ORM\Column(name="name", type="string", length=255, nullable=false)
  26.      */
  27.     private $name;
  28.     /**
  29.      * @ORM\ManyToMany(targetEntity="App\CasinoBundle\Entity\Casino", mappedBy="keywords", cascade={"persist"})
  30.      * @ORM\JoinTable(
  31.      *     name="casino_keyword",
  32.      *     joinColumns={
  33.      *          @ORM\JoinColumn(name="casino_id", referencedColumnName="id")
  34.      *     },
  35.      *     inverseJoinColumns={
  36.      *          @ORM\JoinColumn(name="keyword_id", referencedColumnName="id")
  37.      *     }
  38.      * )
  39.      */
  40.     private $casinos;
  41.     public function __construct()
  42.     {
  43.         $this->casinos = new ArrayCollection();
  44.     }
  45.     public function __toString()
  46.     {
  47.         return $this->name;
  48.     }
  49.     /**
  50.      * @return int
  51.      */
  52.     public function getId(): int
  53.     {
  54.         return $this->id;
  55.     }
  56.     /**
  57.      * @param int $id
  58.      */
  59.     public function setId(int $id): void
  60.     {
  61.         $this->id $id;
  62.     }
  63.     /**
  64.      * @return string
  65.      */
  66.     public function getName(): string
  67.     {
  68.         return $this->name;
  69.     }
  70.     /**
  71.      * @param string $name
  72.      * @return $this
  73.      */
  74.     public function setName(string $name): self
  75.     {
  76.         $this->name substr($name,0,120);
  77.         return $this;
  78.     }
  79.     /**
  80.      * @return Collection|Casino[]
  81.      */
  82.     public function getCasinos(): Collection
  83.     {
  84.         return $this->casinos;
  85.     }
  86.     public function addCasino(Casino $casino): self
  87.     {
  88.         if (!$this->casinos->contains($casino)) {
  89.             $this->casinos[] = $casino;
  90.             $casino->addKeyword($this);
  91.         }
  92.         return $this;
  93.     }
  94.     public function removeCasino(Casino $casino): self
  95.     {
  96.         if ($this->casinos->contains($casino)) {
  97.             $this->casinos->removeElement($casino);
  98.             $casino->removeKeyword($this);
  99.         }
  100.         return $this;
  101.     }
  102. }