src/Entity/AwardLog.php line 36

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  6. use App\Repository\AwardLogRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. /**
  12.  * @ORM\Entity(repositoryClass=AwardLogRepository::class)
  13.  * @ApiResource(
  14.  *     normalizationContext={
  15.  *         "groups"={"award_log:read"}
  16.  *     },
  17.  *     denormalizationContext={
  18.  *          "groups"={"award_log:write"}
  19.  *     },
  20.  *     collectionOperations={
  21.  *          "get"={"security"="is_granted('ROLE_ADMIN')"}
  22.  *     },
  23.  *     itemOperations={
  24.  *          "get"={"security"="is_granted('ROLE_ADMIN')"}
  25.  *     }
  26.  * )
  27.  * @ApiFilter(SearchFilter::class, properties={
  28.  *      "id": "exact", "type": "exact", "subType": "exact", "tvUser.id": "exact", 
  29.  *      "tvUser.tvCompany.id": "exact", "award.id": "exact"
  30.  * })
  31.  */
  32. class AwardLog
  33. {
  34.     const AWARD_EVENT "award_event";
  35.     const AWARD_START "award_start";
  36.     const AWARD_END "award_end";
  37.     const AWARD_REDO "award_redo";
  38.     const USER_EVENT "user_event";
  39.     const USER_WON "user_won";
  40.     const USER_LOST "user_lost";
  41.     const TYPES = [
  42.         self::AWARD_EVENT,
  43.         self::USER_EVENT,
  44.     ];
  45.     const SUBTYPES = [
  46.         self::AWARD_START,
  47.         self::AWARD_END,
  48.         self::AWARD_REDO,
  49.         self::USER_WON,
  50.         self::USER_LOST
  51.     ];
  52.     /**
  53.      * @ORM\Id
  54.      * @ORM\GeneratedValue
  55.      * @ORM\Column(type="integer")
  56.      * @Groups({"award_config:read"})
  57.      */
  58.     private $id;
  59.     /**
  60.      * @ORM\ManyToOne(targetEntity=TvUser::class, inversedBy="awardLogs", cascade={"persist", "refresh"})
  61.      * @Groups({"award_config:read"})
  62.      */
  63.     private $tvUser;
  64.     /**
  65.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="awardLogs", cascade={"persist", "refresh"})
  66.      * @Groups({"award_config:read"})
  67.      */
  68.     private $user;
  69.     /**
  70.      * @ORM\ManyToOne(targetEntity=Award::class, inversedBy="awardLogs")
  71.      * @Groups({"award_config:read"})
  72.      */
  73.     private $award;
  74.     /**
  75.      * @ORM\ManyToOne(targetEntity=AwardOperation::class)
  76.      * @Groups({"award_config:read"})
  77.      */
  78.     private $operation;
  79.     /**
  80.      * @ORM\Column(type="integer", nullable=true)
  81.      * @Groups({"award_config:read"})
  82.      */
  83.     private $pointsWon;
  84.     /**
  85.      * @ORM\Column(type="integer", nullable=true)
  86.      * @Groups({"award_config:read"})
  87.      */
  88.     private $pointsTotal 0;
  89.     /**
  90.      * @ORM\Column(type="string", length=255, nullable=true)
  91.      * @Assert\Choice(choices=self::TYPES)
  92.      * @Groups({"award_config:read"})
  93.      */
  94.     private $type;
  95.     
  96.     /**
  97.      * @ORM\Column(type="string", length=255, nullable=true)
  98.      * @Assert\Choice(choices=self::SUBTYPES)
  99.      * @Groups({"award_config:read"})
  100.      */
  101.     private $subType;
  102.     
  103.     /**
  104.      * @ORM\Column(type="datetime")
  105.      * @Gedmo\Timestampable(on="create")
  106.      */
  107.     private $createdAt;
  108.     public function __construct()
  109.     {
  110.         $this->pointsTotal 0;
  111.     }
  112.     public function getId(): ?int
  113.     {
  114.         return $this->id;
  115.     }
  116.     public function getCreatedAt(): ?\DateTimeInterface
  117.     {
  118.         return $this->createdAt;
  119.     }
  120.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  121.     {
  122.         $this->createdAt $createdAt;
  123.         return $this;
  124.     }
  125.     public function getType(): ?string
  126.     {
  127.         return $this->type;
  128.     }
  129.     public function setType(?string $type): self
  130.     {
  131.         $this->type $type;
  132.         return $this;
  133.     }
  134.     public function getSubType(): ?string
  135.     {
  136.         return $this->subType;
  137.     }
  138.     public function setSubType(?string $subType): self
  139.     {
  140.         $this->subType $subType;
  141.         return $this;
  142.     }
  143.     public function getTvUser(): ?TvUser
  144.     {
  145.         return $this->tvUser;
  146.     }
  147.     public function setTvUser(?TvUser $tvUser): self
  148.     {
  149.         $this->tvUser $tvUser;
  150.         return $this;
  151.     }
  152.     public function getUser(): ?User
  153.     {
  154.         return $this->user;
  155.     }
  156.     public function setUser(?User $user): self
  157.     {
  158.         $this->user $user;
  159.         return $this;
  160.     }
  161.     public function getPointsWon(): ?int
  162.     {
  163.         return $this->pointsWon;
  164.     }
  165.     public function setPointsWon(?int $pointsWon): self
  166.     {
  167.         $this->pointsWon $pointsWon;
  168.         return $this;
  169.     }
  170.     public function getPointsTotal(): ?int
  171.     {
  172.         return $this->pointsTotal;
  173.     }
  174.     public function setPointsTotal(?int $pointsTotal): self
  175.     {
  176.         $this->pointsTotal $pointsTotal;
  177.         return $this;
  178.     }
  179.     public function getAward(): ?Award
  180.     {
  181.         return $this->award;
  182.     }
  183.     public function setAward(?Award $award): self
  184.     {
  185.         $this->award $award;
  186.         return $this;
  187.     }
  188.     public function getOperation(): ?AwardOperation
  189.     {
  190.         return $this->operation;
  191.     }
  192.     public function setOperation(?AwardOperation $operation): self
  193.     {
  194.         $this->operation $operation;
  195.         return $this;
  196.     }
  197. }