src/CasinoBundle/Entity/SportType.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\CasinoBundle\Entity;
  3. use App\CmsBundle\Entity\SlugTrait;
  4. use App\CmsBundle\Entity\IdTrait;
  5. use App\CmsBundle\Entity\PublishedTrait;
  6. use App\CmsBundle\Entity\TimeStampedTrait;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11.  * @ORM\Table(
  12.  *     name="sport_type",
  13.  *     indexes={
  14.  *         @ORM\Index(name="sport_type_published_index", columns={"published"}),
  15.  *     },
  16.  *     uniqueConstraints={
  17.  *         @ORM\UniqueConstraint(name="sport_type_slug_uindex", columns={"slug"})
  18.  *     }
  19.  * )
  20.  * @ORM\Entity(
  21.  *     repositoryClass="App\CasinoBundle\Repository\SportTypeRepository"
  22.  * )
  23.  */
  24. class SportType
  25. {
  26.     use IdTrait,
  27.         NameTrait,
  28.         SlugTrait,
  29.         PublishedTrait,
  30.         TimeStampedTrait;
  31.     /**
  32.      * @ORM\ManyToMany(
  33.      *     targetEntity="App\CasinoBundle\Entity\NewBonus",
  34.      *     mappedBy="sportTypes",
  35.      *     fetch="EXTRA_LAZY"
  36.      * )
  37.      */
  38.     private Collection $newBonuses;
  39.     /**
  40.      * @return string
  41.      */
  42.     public function __toString(): string
  43.     {
  44.         return $this->getName();
  45.     }
  46.     public function __construct()
  47.     {
  48.         $this->newBonuses = new ArrayCollection();
  49.     }
  50.     /**
  51.      * @return Collection
  52.      */
  53.     public function getNewBonuses(): Collection
  54.     {
  55.         return $this->newBonuses;
  56.     }
  57.     /**
  58.      * @param NewBonus $bonus
  59.      * @return $this
  60.      */
  61.     public function addNewBonus(NewBonus $bonus): self
  62.     {
  63.         if (!$this->newBonuses->contains($bonus)) {
  64.             $this->newBonuses[] = $bonus;
  65.         }
  66.         return $this;
  67.     }
  68.     /**
  69.      * @param NewBonus $bonus
  70.      * @return $this
  71.      */
  72.     public function removeNewBonus(NewBonus $bonus): self
  73.     {
  74.         $this->newBonuses->removeElement($bonus);
  75.         return $this;
  76.     }
  77. }