src/CasinoBundle/Entity/BonusReaction.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\CasinoBundle\Entity;
  3. use App\CmsBundle\Entity\IdTrait;
  4. use App\CmsBundle\Entity\TimeStampedTrait;
  5. use App\ProfileBundle\Entity\User;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass="App\CasinoBundle\Repository\BonusReactionRepository")
  9.  * @ORM\Table(
  10.  *     name="bonus_reactions",
  11.  *     uniqueConstraints={
  12.  *         @ORM\UniqueConstraint(name="uniq_bonus_user", columns={"bonus_id", "user_id"})
  13.  *     }
  14.  * )
  15.  */
  16. class BonusReaction
  17. {
  18.     use IdTrait,
  19.         TimeStampedTrait;
  20.     /**
  21.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\NewBonus", inversedBy="reactions")
  22.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  23.      */
  24.     private ?NewBonus $bonus null;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity="App\ProfileBundle\Entity\User", inversedBy="bonusReactions")
  27.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  28.      */
  29.     private ?User $user null;
  30.     /**
  31.      * @ORM\Column(type="smallint")
  32.      */
  33.     private int $reactionType;
  34.     /**
  35.      * @return NewBonus|null
  36.      */
  37.     public function getBonus(): ?NewBonus
  38.     {
  39.         return $this->bonus;
  40.     }
  41.     /**
  42.      * @param NewBonus|null $bonus
  43.      * @return $this
  44.      */
  45.     public function setBonus(?NewBonus $bonus): self
  46.     {
  47.         $this->bonus $bonus;
  48.         return $this;
  49.     }
  50.     /**
  51.      * @return User|null
  52.      */
  53.     public function getUser(): ?User
  54.     {
  55.         return $this->user;
  56.     }
  57.     /**
  58.      * @param User|null $user
  59.      * @return $this
  60.      */
  61.     public function setUser(?User $user): self
  62.     {
  63.         $this->user $user;
  64.         return $this;
  65.     }
  66.     /**
  67.      * @return int
  68.      */
  69.     public function getReactionType(): int
  70.     {
  71.         return $this->reactionType;
  72.     }
  73.     /**
  74.      * @param int $reactionType
  75.      * @return $this
  76.      */
  77.     public function setReactionType(int $reactionType): self
  78.     {
  79.         $this->reactionType $reactionType;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return bool
  84.      */
  85.     public function isLike(): bool
  86.     {
  87.         return $this->reactionType === 1;
  88.     }
  89.     /**
  90.      * @return bool
  91.      */
  92.     public function isDislike(): bool
  93.     {
  94.         return $this->reactionType === -1;
  95.     }
  96. }