src/Entity/DailyRewardLog.php line 46

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use ApiPlatform\Core\Annotation\ApiFilter;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
  7. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  8. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  9. use App\Repository\DailyRewardLogRepository;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Gedmo\Mapping\Annotation as Gedmo;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  14. /**
  15.  * @ApiResource(
  16.  *      normalizationContext={"groups"={"daily_reward_log:read"}},
  17.  *      denormalizationContext={"groups"={"daily_reward_log:write"}},
  18.  *      itemOperations={
  19.  *          "get"={"security"="is_granted('ROLE_USER')"},
  20.  *          "patch"={"security"="is_granted('ROLE_USER')"}
  21.  *      },
  22.  *      collectionOperations={
  23.  *          "get"={"security"="is_granted('ROLE_USER')"},
  24.  *          "post"={"security"="is_granted('ROLE_USER')"}
  25.  *      }
  26.  * )
  27.  * @ORM\Entity(repositoryClass=DailyRewardLogRepository::class)
  28.  * @ORM\Table(
  29.  *     name="daily_reward_log",
  30.  *     uniqueConstraints={
  31.  *         @ORM\UniqueConstraint(name="unique_user_date", columns={"user_id", "log_date"})
  32.  *     }
  33.  * )
  34.  * @UniqueEntity(
  35.  *     fields={"user", "logDate"},
  36.  *     message="Un log de récompense quotidienne existe déjà pour cet utilisateur à cette date."
  37.  * )
  38.  * @ApiFilter(SearchFilter::class, properties={"user.id": "exact", "company.id": "exact"})
  39.  * @ApiFilter(BooleanFilter::class, properties={"isCollected"})
  40.  * @ApiFilter(DateFilter::class, properties={"logDate", "notificationScheduledFor", "notificationSentAt"})
  41.  * @ApiFilter(OrderFilter::class)
  42.  */
  43. class DailyRewardLog
  44. {
  45.     /**
  46.      * @ORM\Id
  47.      * @ORM\GeneratedValue
  48.      * @ORM\Column(type="integer")
  49.      * @Groups({"daily_reward_log:read"})
  50.      */
  51.     private $id;
  52.     /**
  53.      * @ORM\ManyToOne(targetEntity=User::class)
  54.      * @ORM\JoinColumn(nullable=false)
  55.      * @Groups({"daily_reward_log:read", "daily_reward_log:write"})
  56.      */
  57.     private $user;
  58.     /**
  59.      * @ORM\ManyToOne(targetEntity=Company::class)
  60.      * @Groups({"daily_reward_log:read", "daily_reward_log:write"})
  61.      */
  62.     private $company;
  63.     /**
  64.      * @ORM\ManyToOne(targetEntity=Teamplay::class)
  65.      * @Groups({"daily_reward_log:read", "daily_reward_log:write"})
  66.      */
  67.     private $teamplay;
  68.     /**
  69.      * Date du log (jour normalisé à minuit)
  70.      * @ORM\Column(type="date")
  71.      * @Groups({"daily_reward_log:read", "daily_reward_log:write"})
  72.      */
  73.     private $logDate;
  74.     /**
  75.      * Indique si l'utilisateur a récupéré ses points
  76.      * @ORM\Column(type="boolean", options={"default": "0"})
  77.      * @Groups({"daily_reward_log:read", "daily_reward_log:write"})
  78.      */
  79.     private $isCollected = false;
  80.     /**
  81.      * Nombre de points disponibles pour cette récompense quotidienne
  82.      * @ORM\Column(type="integer", options={"default": "0"})
  83.      * @Groups({"daily_reward_log:read", "daily_reward_log:write"})
  84.      */
  85.     private $pointAmount = 0;
  86.     /**
  87.      * Heure programmée pour la notification (avec décalage aléatoire)
  88.      * @ORM\Column(type="datetime", nullable=true)
  89.      * @Groups({"daily_reward_log:read"})
  90.      */
  91.     private $notificationScheduledFor;
  92.     /**
  93.      * Date d'envoi de la notification
  94.      * @ORM\Column(type="datetime", nullable=true)
  95.      * @Groups({"daily_reward_log:read"})
  96.      */
  97.     private $notificationSentAt;
  98.     /**
  99.      * Décalage en minutes pour cette notification (pour étaler les connexions)
  100.      * @ORM\Column(type="integer", nullable=true)
  101.      * @Groups({"daily_reward_log:read"})
  102.      */
  103.     private $notificationOffsetMinutes;
  104.     /**
  105.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  106.      * @Gedmo\Timestampable(on="create")
  107.      * @Groups({"daily_reward_log:read"})
  108.      */
  109.     private $createdAt;
  110.     /**
  111.      * @ORM\Column(type="datetime", nullable=true)
  112.      * @Gedmo\Timestampable(on="update")
  113.      * @Groups({"daily_reward_log:read"})
  114.      */
  115.     private $updatedAt;
  116.     public function getId(): ?int 
  117.     { 
  118.         return $this->id; 
  119.     }
  120.     public function getUser(): ?User 
  121.     { 
  122.         return $this->user; 
  123.     }
  124.     
  125.     public function setUser(?User $user): self 
  126.     { 
  127.         $this->user = $user; 
  128.         return $this; 
  129.     }
  130.     public function getCompany(): ?Company 
  131.     { 
  132.         return $this->company; 
  133.     }
  134.     
  135.     public function setCompany(?Company $company): self 
  136.     { 
  137.         $this->company = $company; 
  138.         return $this; 
  139.     }
  140.     public function getTeamplay(): ?Teamplay 
  141.     { 
  142.         return $this->teamplay; 
  143.     }
  144.     
  145.     public function setTeamplay(?Teamplay $teamplay): self 
  146.     { 
  147.         $this->teamplay = $teamplay; 
  148.         return $this; 
  149.     }
  150.     public function getLogDate(): ?\DateTimeInterface 
  151.     { 
  152.         return $this->logDate; 
  153.     }
  154.     
  155.     public function setLogDate(\DateTimeInterface $logDate): self 
  156.     { 
  157.         $this->logDate = $logDate; 
  158.         return $this; 
  159.     }
  160.     public function getIsCollected(): bool 
  161.     { 
  162.         return $this->isCollected; 
  163.     }
  164.     
  165.     public function setIsCollected(bool $isCollected): self 
  166.     { 
  167.         $this->isCollected = $isCollected; 
  168.         return $this; 
  169.     }
  170.     public function getPointAmount(): int 
  171.     { 
  172.         return $this->pointAmount; 
  173.     }
  174.     
  175.     public function setPointAmount(int $pointAmount): self 
  176.     { 
  177.         $this->pointAmount = $pointAmount; 
  178.         return $this; 
  179.     }
  180.     public function getNotificationScheduledFor(): ?\DateTimeInterface 
  181.     { 
  182.         return $this->notificationScheduledFor; 
  183.     }
  184.     
  185.     public function setNotificationScheduledFor(?\DateTimeInterface $notificationScheduledFor): self 
  186.     { 
  187.         $this->notificationScheduledFor = $notificationScheduledFor; 
  188.         return $this; 
  189.     }
  190.     public function getNotificationSentAt(): ?\DateTimeInterface 
  191.     { 
  192.         return $this->notificationSentAt; 
  193.     }
  194.     
  195.     public function setNotificationSentAt(?\DateTimeInterface $notificationSentAt): self 
  196.     { 
  197.         $this->notificationSentAt = $notificationSentAt; 
  198.         return $this; 
  199.     }
  200.     public function getNotificationOffsetMinutes(): ?int 
  201.     { 
  202.         return $this->notificationOffsetMinutes; 
  203.     }
  204.     
  205.     public function setNotificationOffsetMinutes(?int $notificationOffsetMinutes): self 
  206.     { 
  207.         $this->notificationOffsetMinutes = $notificationOffsetMinutes; 
  208.         return $this; 
  209.     }
  210.     public function getCreatedAt(): ?\DateTimeInterface 
  211.     { 
  212.         return $this->createdAt; 
  213.     }
  214.     
  215.     public function setCreatedAt(\DateTimeInterface $createdAt): self 
  216.     { 
  217.         $this->createdAt = $createdAt; 
  218.         return $this; 
  219.     }
  220.     public function getUpdatedAt(): ?\DateTimeInterface 
  221.     { 
  222.         return $this->updatedAt; 
  223.     }
  224.     
  225.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self 
  226.     { 
  227.         $this->updatedAt = $updatedAt; 
  228.         return $this; 
  229.     }
  230. }