src/Entity/TeamplayChallenge.php line 88

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\Annotation\ApiSubresource;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  7. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
  8. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  9. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  10. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\ExistsFilter;
  11. use ApiPlatform\Core\Serializer\Filter\GroupFilter;
  12. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  13. use App\Repository\TeamplayChallengeRepository;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use Doctrine\Common\Collections\Collection;
  16. use Doctrine\ORM\Mapping as ORM;
  17. use Gedmo\Mapping\Annotation as Gedmo;
  18. use Symfony\Component\HttpFoundation\File\UploadedFile;
  19. use Symfony\Component\Serializer\Annotation\Groups;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. use App\Entity\KinestexExercise;
  22. /**
  23.  * @ApiResource(
  24.  *      normalizationContext={
  25.  *          "groups"={"teamplay_challenge:read"}
  26.  *      },
  27.  *      denormalizationContext={
  28.  *          "groups"={"teamplay_challenge:write"}
  29.  *      },
  30.  *      itemOperations={
  31.  *          "get"={
  32.  *              "security"="is_granted('ROLE_USER')"
  33.  *          },
  34.  *          "patch"={
  35.  *              "security"="is_granted('ROLE_ADMIN')"
  36.  *          },
  37.  *          "delete"={
  38.  *              "security"="is_granted('ROLE_ADMIN')"
  39.  *          }
  40.  *      },
  41.  *      collectionOperations={
  42.  *          "get"={
  43.  *              "security"="is_granted('ROLE_USER')"
  44.  *          }, 
  45.  *          "get_client_teamplay_collected"={
  46.  *              "security"="is_granted('ROLE_CLIENT')",
  47.  *              "method"="GET",
  48.  *              "description"="Get completed TeamplayChallenge by a Client",
  49.  *              "controller"="App\Controller\Api\TeamplayChallengeController::getClientTeamplayChallengeCompleted"
  50.  *          }, 
  51.  *          "post"={
  52.  *              "security"="is_granted('ROLE_ADMIN')"
  53.  *          },
  54.  *          "post_update"={
  55.  *              "security"="is_granted('ROLE_ADMIN')",
  56.  *              "path"="/teamplay_challenges/{id}",
  57.  *              "description"="Update a TeamplayChallenge with method POST (using content-type: 'multipart')",
  58.  *              "method"="POST",
  59.  *              "controller"="App\Controller\Api\TeamplayChallengeController::update"
  60.  *          }
  61.  *      }
  62.  * )
  63.  * @ORM\Entity(repositoryClass=TeamplayChallengeRepository::class)
  64.  * @ApiFilter(SearchFilter::class, 
  65.  *      strategy="exact", 
  66.  *      properties={"active", "teamplay.id", "name": "partial", "type", "company.id", "isTemplate"}
  67.  * )
  68.  * @ApiFilter(ExistsFilter::class, properties={"teamplay", "company", "video", "survey", "type"})
  69.  * @ApiFilter(BooleanFilter::class, properties={"active", "isTemplate"})
  70.  * @ApiFilter(DateFilter::class, properties={"dateStart", "dateEnd"})
  71.  * @ApiFilter(OrderFilter::class)
  72.  * @ApiFilter(GroupFilter::class, 
  73.  *      arguments={
  74.  *          "parameterName": "groups", 
  75.  *          "overrideDefaultGroups": true
  76.  *      }
  77.  * )
  78.  * @ApiFilter(PropertyFilter::class, 
  79.  *      arguments={
  80.  *          "parameterName"="fields", 
  81.  *          "overrideDefaultProperties"=true
  82.  *     }
  83.  * )
  84.  */
  85. class TeamplayChallenge
  86. {
  87.     const TYPE_STEP = "step";
  88.     const TYPE_BIKE = "bike";
  89.     const TYPE_RUN = "run";
  90.     const TYPE_RECURRENT_STEP = "recurrent_step";
  91.     const TYPE_RECURRENT_BIKE = "recurrent_bike";
  92.     const TYPE_RECURRENT_RUN = "recurrent_run";
  93.     const TYPE_RECURRENT_RANKING_AWARD = "recurrent_ranking_award";
  94.     const TYPE_VIDEO_PHYSICAL = "video_physical";
  95.     const TYPE_VIDEO_INTERVIEW = "video_interview";
  96.     const TYPE_QUIZ = "quiz";
  97.     const TYPE_KINESTEX = "kinestex";
  98.     const TYPE_RECURRENT_KINESTEX = 'recurrent_kinestex';
  99.     const TYPE_DAILY_REWARD = "daily_reward";
  100.     const TYPES = [
  101.         self::TYPE_STEP,
  102.         self::TYPE_BIKE,
  103.         self::TYPE_RUN,
  104.         self::TYPE_RECURRENT_STEP,
  105.         self::TYPE_RECURRENT_BIKE,
  106.         self::TYPE_RECURRENT_RUN,
  107.         self::TYPE_RECURRENT_RANKING_AWARD,
  108.         self::TYPE_VIDEO_PHYSICAL,
  109.         self::TYPE_VIDEO_INTERVIEW,
  110.         self::TYPE_QUIZ,
  111.         self::TYPE_KINESTEX,
  112.         self::TYPE_DAILY_REWARD,
  113.     ];
  114.     const STATUS_IN_PROGRESS = "in_progress";
  115.     const STATUS_IN_COMING = "in_coming";
  116.     const STATUS_PASSED = "passed";
  117.     const STATUS = [
  118.         self::STATUS_IN_PROGRESS,
  119.         self::STATUS_IN_COMING,
  120.         self::STATUS_PASSED
  121.     ];
  122.     const EVERY_TYPE_HOUR = "hour";
  123.     const EVERY_TYPE_DAY = "day";
  124.     const EVERY_TYPE_WEEK = "week";
  125.     const EVERY_TYPE_MONTH = "month";
  126.     const EVERY_TYPE_YEAR = "year";
  127.     const EVERY_DATE_TYPES = [
  128.         self::EVERY_TYPE_HOUR,
  129.         self::EVERY_TYPE_DAY,
  130.         self::EVERY_TYPE_WEEK,
  131.         self::EVERY_TYPE_MONTH,
  132.         self::EVERY_TYPE_YEAR,
  133.     ];
  134.     /**
  135.      * @ORM\Id
  136.      * @ORM\GeneratedValue
  137.      * @ORM\Column(type="integer")
  138.      * @Groups({"teamplay_challenge:read:id", "teamplay_challenge:read", "teamplay_challenge_simple", "teamplay:read", "challenge_form"})
  139.      */
  140.     private $id;
  141.     /**
  142.      * @ORM\Column(type="string", length=255, nullable=true)
  143.      * @Groups({"teamplay_challenge:read:name", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read", "challenge_form"})
  144.      */
  145.     private $name;
  146.     /**
  147.      * @ORM\Column(type="text", nullable=true)
  148.      * @Groups({"teamplay_challenge:read:description", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  149.      */
  150.     private $description;
  151.     /**
  152.      * @ORM\Column(type="string", length=255, nullable=true)
  153.      * @Assert\Choice(choices=self::TYPES)
  154.      * @Groups({"teamplay_challenge:read:type", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  155.      */
  156.     private $type;
  157.     /**
  158.      * @ORM\ManyToOne(targetEntity=MediaObject::class)
  159.      * @Groups({"teamplay_challenge:read:picture", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  160.      */
  161.     private $picture;
  162.     /**
  163.      * @ORM\Column(type="integer", nullable=true)
  164.      * @Groups({"teamplay_challenge:read:duration", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  165.      */
  166.     private $duration;
  167.     /**
  168.      * @ORM\Column(type="integer", nullable=true)
  169.      * @Groups({"teamplay_challenge:read:pointAmount", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  170.      */
  171.     private $pointAmount;
  172.     /**
  173.      * @ORM\Column(type="integer", nullable=true)
  174.      * @Groups({"teamplay_challenge:read:stepAmount", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  175.      */
  176.     private $stepAmount;
  177.     /**
  178.      * @ORM\Column(type="integer", nullable=true)
  179.      * @Groups({"teamplay_challenge:read:dayStart", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  180.      */
  181.     private $dayStart;
  182.     /**
  183.      * @ORM\Column(type="integer", nullable=true)
  184.      * @Groups({"teamplay_challenge:read:dayEnd", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  185.      */
  186.     private $dayEnd;
  187.     /**
  188.      * @ORM\Column(type="datetime", nullable=true)
  189.      * @Groups({"teamplay_challenge:read:dateStart", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  190.      */
  191.     private $dateStart;
  192.     /**
  193.      * @ORM\Column(type="datetime", nullable=true)
  194.      * @Groups({"teamplay_challenge:read:dateEnd", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  195.      */
  196.     private $dateEnd;
  197.     /**
  198.      * @ORM\ManyToOne(targetEntity=Video::class, inversedBy="teamplayChallenges")
  199.      * @Groups({"teamplay_challenge:read:video", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  200.      */
  201.     private $video;
  202.     /**
  203.      * @ORM\ManyToOne(targetEntity=Survey::class, inversedBy="teamplayChallenges", cascade={"persist", "refresh", "remove"})
  204.      * @Groups({"teamplay_challenge:read:survey", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  205.      */
  206.     private $survey;
  207.     /**
  208.      * @ORM\Column(type="boolean", nullable=true, options={"default": "1"})
  209.      * @Groups({"teamplay_challenge:read:isTemplate", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  210.      */
  211.     private $isTemplate = true;
  212.     /**
  213.      * @ORM\Column(type="integer", nullable=true)
  214.      * @Groups({"teamplay_challenge:read:awardAmount", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  215.      */
  216.     private $awardAmount;
  217.     /**
  218.      * @ORM\Column(type="boolean", options={"default": "0"})
  219.      * @Groups({"teamplay_challenge:read:isMultipleWinnable", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  220.      */
  221.     private $isMultipleWinnable = false;
  222.     /**
  223.      * @ORM\Column(type="integer", nullable=true)
  224.      * @Groups({"teamplay_challenge:read:everyInt", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  225.      */
  226.     private $everyInt;
  227.     /**
  228.      * @ORM\Column(type="string", length=255, nullable=true)
  229.      * @Groups({"teamplay_challenge:read:everyDateType", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  230.      */
  231.     private $everyDateType;
  232.     /**
  233.      * @ORM\ManyToOne(targetEntity=TvCompany::class, inversedBy="teamplayChallenges")
  234.      */
  235.     private $tvCompany;
  236.     /**
  237.      * @ORM\ManyToOne(targetEntity=Company::class, inversedBy="teamplayChallenges")
  238.      * @Groups({"teamplay_challenge:read:company", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  239.      */
  240.     private $company;
  241.     /**
  242.      * @ORM\Column(type="boolean", nullable=true, options={"default": "1"})
  243.      * @Groups({"teamplay_challenge:read:active", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  244.      */
  245.     private $active = true;
  246.     /**
  247.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  248.      * @Gedmo\Timestampable(on="create")
  249.      * @Groups({"teamplay_challenge:read:createdAt", "teamplay_challenge:read", "teamplay_challenge_simple"})
  250.      */
  251.     private $createdAt;
  252.     /**
  253.      * @ORM\Column(type="datetime", nullable=true)
  254.      * @Gedmo\Timestampable(on="update")
  255.      * @Groups({"teamplay_challenge:read:updatedAt", "teamplay_challenge:read", "teamplay_challenge_simple"})
  256.      */
  257.     private $updatedAt;
  258.     /**
  259.      * @ORM\ManyToOne(targetEntity=Teamplay::class, inversedBy="challenges", cascade={"refresh"})
  260.      * @Groups({"teamplay_challenge:read:teamplay", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple"})
  261.      */
  262.     private $teamplay;
  263.     /**
  264.      * @ORM\OneToMany(targetEntity=TeamplayLog::class, mappedBy="teamplayChallenge", cascade={"persist", "refresh", "remove"})
  265.      */
  266.     private $teamplayLogs;
  267.     /**
  268.      * Champ Custom (PostLoad)
  269.      * Permet de savoir si le TeamplayChallenge a Ã©té complété par le Client connecté
  270.      * @var ?bool
  271.      * @Groups({"teamplay_challenge:read:isCompleted", "teamplay_challenge:read"})
  272.      */
  273.     public $isCompleted = null;
  274.     /**
  275.      * Champ Custom (PostLoad)
  276.      * Permet de savoir si le Client connecté a récupéré les points du TeamplayChallenge
  277.      * @var ?bool
  278.      * @Groups({"teamplay_challenge:read:isCollected", "teamplay_challenge:read"})
  279.      */
  280.     public $isCollected = null;
  281.     /**
  282.      * Champ Custom (PostLoad)
  283.      * Nombre de pas effectués par le Client connecté durant ce challenge
  284.      * @var ?int
  285.      * @Groups({"teamplay_challenge:read:userStepsAmount", "teamplay_challenge:read"})
  286.      */
  287.     public $userStepsAmount = null;
  288.     /**
  289.      * Distance en mètres requise pour gagner des points (seuil récurrent vélo)
  290.      * @ORM\Column(type="integer", nullable=true)
  291.      * @Groups({"teamplay_challenge:read:bikeAmount", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  292.      */
  293.     private $bikeAmount;
  294.     /**
  295.      * Champ Custom (PostLoad)
  296.      * Nombre de mètres parcourus Ã  vélo par le Client connecté durant ce challenge (avec décimales)
  297.      * @var ?float
  298.      * @Groups({"teamplay_challenge:read:userBikeAmount", "teamplay_challenge:read"})
  299.      */
  300.     public $userBikeAmount = null;
  301.     /**
  302.      * Distance en mètres requise pour gagner des points (seuil récurrent course Ã  pied)
  303.      * @ORM\Column(type="integer", nullable=true)
  304.      * @Groups({"teamplay_challenge:read:runAmount", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  305.      */
  306.     private $runAmount;
  307.     /**
  308.      * Champ Custom (PostLoad)
  309.      * Nombre de mètres parcourus en course Ã  pied par le Client connecté durant ce challenge (avec décimales)
  310.      * @var ?float
  311.      * @Groups({"teamplay_challenge:read:userRunAmount", "teamplay_challenge:read"})
  312.      */
  313.     public $userRunAmount = null;
  314.     /**
  315.      * Score KinesteX requis pour valider le challenge (pourcentage de 0 Ã  100)
  316.      * @ORM\Column(type="integer", nullable=true)
  317.      * @Groups({"teamplay_challenge:read:kinestexAmount", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  318.      */
  319.     private $kinestexAmount;
  320.     /**
  321.      * Champ Custom (PostLoad)
  322.      * Score de précision KinesteX obtenu par le Client connecté durant ce challenge
  323.      * @var ?float
  324.      * @Groups({"teamplay_challenge:read:userKinestexAmount", "teamplay_challenge:read"})
  325.      */
  326.     public $userKinestexAmount = null;
  327.     /**
  328.      * Champ Custom (PostLoad)
  329.      * Nombre total de répétitions effectuées par le Client durant ce challenge KinesteX
  330.      * @var ?int
  331.      * @Groups({"teamplay_challenge:read:userKinestexReps", "teamplay_challenge:read"})
  332.      */
  333.     public $userKinestexReps = null;
  334.     /**
  335.      * Champ Custom (PostLoad)  
  336.      * Durée totale en secondes effectuée par le Client durant ce challenge KinesteX
  337.      * @var ?int
  338.      * @Groups({"teamplay_challenge:read:userKinestexDuration", "teamplay_challenge:read"})
  339.      */
  340.     public $userKinestexDuration = null;
  341.     /**
  342.      * Champ Custom (PostLoad)
  343.      * Nombre total de sessions KinesteX effectuées par le Client durant ce challenge
  344.      * @var ?int
  345.      * @Groups({"teamplay_challenge:read:userKinestexSessions", "teamplay_challenge:read"})
  346.      */
  347.     public $userKinestexSessions = null;
  348.     /**
  349.      * Champ Custom (PostLoad)
  350.      * Nombre de sessions KinesteX complétées (80%+) par le Client durant ce challenge
  351.      * @var ?int
  352.      * @Groups({"teamplay_challenge:read:userKinestexCompletedSessions", "teamplay_challenge:read"})
  353.      */
  354.     public $userKinestexCompletedSessions = null;
  355.     /**
  356.      * Champ Custom (PostLoad)
  357.      * Pourcentage moyen de complétion des sessions KinesteX du Client durant ce challenge
  358.      * @var ?float
  359.      * @Groups({"teamplay_challenge:read:userKinestexAvgAccuracy", "teamplay_challenge:read"})
  360.      */
  361.     public $userKinestexAvgAccuracy = null;
  362.     /**
  363.      * Points attribués pour un score KinesteX entre 10% et 40%
  364.      * @ORM\Column(type="integer", nullable=true)
  365.      * @Groups({"teamplay_challenge:read:kinestexPointsLow", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  366.      */
  367.     private $kinestexPointsLow;
  368.     /**
  369.      * Points attribués pour un score KinesteX entre 40% et 70%
  370.      * @ORM\Column(type="integer", nullable=true)
  371.      * @Groups({"teamplay_challenge:read:kinestexPointsMedium", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  372.      */
  373.     private $kinestexPointsMedium;
  374.     /**
  375.      * Points attribués pour un score KinesteX entre 70% et 100%
  376.      * @ORM\Column(type="integer", nullable=true)
  377.      * @Groups({"teamplay_challenge:read:kinestexPointsHigh", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  378.      */
  379.     private $kinestexPointsHigh;
  380.     /**
  381.      * Exercice KinesteX associé
  382.      * @ORM\ManyToOne(targetEntity=KinestexExercise::class)
  383.      * @Groups({"teamplay_challenge:read", "teamplay_challenge:write"})
  384.      */
  385.     private $kinestexExercise;
  386.     /**
  387.      * Objectif de répétitions pour l'exercice KinesteX (si type repetition)
  388.      * @ORM\Column(type="integer", nullable=true)
  389.      * @Groups({"teamplay_challenge:read", "teamplay_challenge:write"})
  390.      */
  391.     private $kinestexRepetitions;
  392.     /**
  393.      * Objectif de durée en secondes pour l'exercice KinesteX (si type duration)
  394.      * @ORM\Column(type="integer", nullable=true)
  395.      * @Groups({"teamplay_challenge:read", "teamplay_challenge:write"})
  396.      */
  397.     private $kinestexDuration;
  398.     /**
  399.      * Points attribués pour la récompense quotidienne
  400.      * @ORM\Column(type="integer", nullable=true)
  401.      * @Groups({"teamplay_challenge:read:dailyRewardPoints", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  402.      */
  403.     private $dailyRewardPoints;
  404.     /**
  405.      * Heure de base pour l'envoi des notifications (format HH:MM)
  406.      * @ORM\Column(type="string", length=5, nullable=true)
  407.      * @Groups({"teamplay_challenge:read:notificationBaseTime", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  408.      */
  409.     private $notificationBaseTime;
  410.     /**
  411.      * Décalage maximum en minutes pour Ã©taler les notifications
  412.      * @ORM\Column(type="integer", nullable=true, options={"default": "120"})
  413.      * @Groups({"teamplay_challenge:read:notificationMaxOffset", "teamplay_challenge:read", "teamplay_challenge:write", "teamplay_challenge_simple", "teamplay:read"})
  414.      */
  415.     private $notificationMaxOffset = 120;
  416.     public function __construct()
  417.     {
  418.         $this->teamplayLogs = new ArrayCollection();
  419.     }
  420.     public function getId(): ?int
  421.     {
  422.         return $this->id;
  423.     }
  424.     public function setId(?int $id): self
  425.     {
  426.         $this->id = $id;
  427.         return $this;
  428.     }
  429.     public function getName(): ?string
  430.     {
  431.         return $this->name;
  432.     }
  433.     public function setName(?string $name): self
  434.     {
  435.         $this->name = $name;
  436.         return $this;
  437.     }
  438.     public function getDescription(): ?string
  439.     {
  440.         return $this->description;
  441.     }
  442.     public function setDescription(?string $description): self
  443.     {
  444.         $this->description = $description;
  445.         return $this;
  446.     }
  447.     public function getType(): ?string
  448.     {
  449.         return $this->type;
  450.     }
  451.     public function setType(?string $type): self
  452.     {
  453.         $this->type = $type;
  454.         return $this;
  455.     }
  456.     public function getPicture(): ?MediaObject
  457.     {
  458.         return $this->picture;
  459.     }
  460.     public function setPicture(?MediaObject $picture): self
  461.     {
  462.         $this->picture = $picture;
  463.         return $this;
  464.     }
  465.     /**
  466.      * @Groups({"teamplay_challenge:write"})
  467.      */
  468.     public function setPictureFile($file = null): self
  469.     {
  470.         if ($file instanceof UploadedFile) {
  471.             $picture = empty($this->picture) ? new MediaObject : $this->picture;
  472.             $picture->setFile($file);
  473.             $this->setPicture($picture);
  474.         }
  475.         return $this;
  476.     }
  477.     public function getDuration(): ?int
  478.     {
  479.         return $this->duration;
  480.     }
  481.     public function setDuration(?int $duration): self
  482.     {
  483.         $this->duration = $duration;
  484.         return $this;
  485.     }
  486.     public function getPointAmount(): ?int
  487.     {
  488.         return $this->pointAmount;
  489.     }
  490.     public function setPointAmount(?int $pointAmount): self
  491.     {
  492.         $this->pointAmount = $pointAmount;
  493.         return $this;
  494.     }
  495.     public function getStepAmount(): ?int
  496.     {
  497.         return $this->stepAmount;
  498.     }
  499.     public function setStepAmount(?int $stepAmount): self
  500.     {
  501.         $this->stepAmount = $stepAmount;
  502.         return $this;
  503.     }
  504.     public function getDayStart(): ?int
  505.     {
  506.         return $this->dayStart;
  507.     }
  508.     public function setDayStart(?int $dayStart): self
  509.     {
  510.         $this->dayStart = $dayStart;
  511.         return $this;
  512.     }
  513.     public function getDayEnd(): ?int
  514.     {
  515.         return $this->dayEnd;
  516.     }
  517.     public function setDayEnd(?int $dayEnd): self
  518.     {
  519.         $this->dayEnd = $dayEnd;
  520.         return $this;
  521.     }
  522.     public function getDateStart(): ?\DateTimeInterface
  523.     {
  524.         return $this->dateStart;
  525.     }
  526.     public function setDateStart(?\DateTimeInterface $dateStart = null): self
  527.     {
  528.         $this->dateStart = $dateStart;
  529.         return $this;
  530.     }
  531.     public function getDateEnd(): ?\DateTimeInterface
  532.     {
  533.         return $this->dateEnd;
  534.     }
  535.     public function setDateEnd(?\DateTimeInterface $dateEnd): self
  536.     {
  537.         $this->dateEnd = $dateEnd;
  538.         return $this;
  539.     }
  540.     public function getVideo(): ?Video
  541.     {
  542.         return $this->video;
  543.     }
  544.     public function setVideo(?Video $video): self
  545.     {
  546.         $this->video = $video;
  547.         return $this;
  548.     }
  549.     public function getSurvey(): ?Survey
  550.     {
  551.         return $this->survey;
  552.     }
  553.     public function setSurvey(?Survey $survey): self
  554.     {
  555.         $this->survey = $survey;
  556.         return $this;
  557.     }
  558.     public function isTemplate(): bool
  559.     {
  560.         return $this->getIsTemplate();
  561.     }
  562.     public function getIsTemplate(): ?bool
  563.     {
  564.         return $this->isTemplate;
  565.     }
  566.     public function setIsTemplate(?bool $isTemplate): self
  567.     {
  568.         $this->isTemplate = $isTemplate;
  569.         return $this;
  570.     }
  571.     public function getTvCompany(): ?TvCompany
  572.     {
  573.         return $this->tvCompany;
  574.     }
  575.     public function setTvCompany(?TvCompany $tvCompany): self
  576.     {
  577.         $this->tvCompany = $tvCompany;
  578.         return $this;
  579.     }
  580.     public function getCompany(): ?Company
  581.     {
  582.         return $this->company;
  583.     }
  584.     public function setCompany(?Company $company): self
  585.     {
  586.         $this->company = $company;
  587.         return $this;
  588.     }
  589.     public function getTeamplay(): ?Teamplay
  590.     {
  591.         return $this->teamplay;
  592.     }
  593.     public function setTeamplay(?Teamplay $teamplay): self
  594.     {
  595.         $this->teamplay = $teamplay;
  596.         return $this;
  597.     }
  598.     public function getActive(): ?bool
  599.     {
  600.         return $this->active;
  601.     }
  602.     public function setActive(?bool $active): self
  603.     {
  604.         $this->active = $active;
  605.         return $this;
  606.     }
  607.     public function getCreatedAt(): ?\DateTimeInterface
  608.     {
  609.         return $this->createdAt;
  610.     }
  611.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  612.     {
  613.         $this->createdAt = $createdAt;
  614.         return $this;
  615.     }
  616.     public function getUpdatedAt(): ?\DateTimeInterface
  617.     {
  618.         return $this->updatedAt;
  619.     }
  620.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  621.     {
  622.         $this->updatedAt = $updatedAt;
  623.         return $this;
  624.     }
  625.     /**
  626.      * @Groups({"teamplay_challenge:read:isInProgress", "teamplay_challenge:read", "teamplay_challenge_simple"})
  627.      */
  628.     public function isInProgress(): ?bool
  629.     {
  630.         $today = new \DateTime("now");
  631.         if ($this->getDateStart() <= $today && $this->getDateEnd() > $today) {
  632.             return true;
  633.         }
  634.         return false;
  635.     }
  636.     /**
  637.      * @Groups({"teamplay_challenge:read:isInComing", "teamplay_challenge:read", "teamplay_challenge_simple"})
  638.      */
  639.     public function isInComing(): ?bool
  640.     {
  641.         $today = new \DateTime("now");
  642.         if ($this->getDateStart() > $today) {
  643.             return true;
  644.         }
  645.         return false;
  646.     }
  647.     /**
  648.      * @Groups({"teamplay_challenge:read:isPassed", "teamplay_challenge:read", "teamplay_challenge_simple"})
  649.      */
  650.     public function isPassed(): ?bool
  651.     {
  652.         $today = new \DateTime("now");
  653.         if ($this->getDateEnd() < $today) {
  654.             return true;
  655.         }
  656.         return false;
  657.     }
  658.     /**
  659.      * @return Collection|TeamplayLog[]
  660.      */
  661.     public function getTeamplayLogs(): Collection
  662.     {
  663.         return $this->teamplayLogs;
  664.     }
  665.     public function addTeamplayLog(TeamplayLog $teamplayLog): self
  666.     {
  667.         if (!$this->teamplayLogs->contains($teamplayLog)) {
  668.             $this->teamplayLogs[] = $teamplayLog;
  669.             $teamplayLog->setTeamplayChallenge($this);
  670.         }
  671.         return $this;
  672.     }
  673.     public function removeTeamplayLog(TeamplayLog $teamplayLog): self
  674.     {
  675.         if ($this->teamplayLogs->removeElement($teamplayLog)) {
  676.             if ($teamplayLog->getTeamplayChallenge() === $this) {
  677.                 $teamplayLog->setTeamplayChallenge(null);
  678.             }
  679.         }
  680.         return $this;
  681.     }
  682.     public function getAwardAmount(): ?int
  683.     {
  684.         return $this->awardAmount;
  685.     }
  686.     public function setAwardAmount(?int $awardAmount): self
  687.     {
  688.         $this->awardAmount = $awardAmount;
  689.         return $this;
  690.     }
  691.     public function getIsMultipleWinnable(): ?bool
  692.     {
  693.         return $this->isMultipleWinnable;
  694.     }
  695.     public function setIsMultipleWinnable(bool $isMultipleWinnable): self
  696.     {
  697.         $this->isMultipleWinnable = $isMultipleWinnable;
  698.         return $this;
  699.     }
  700.     public function getEveryInt(): ?int
  701.     {
  702.         return $this->everyInt;
  703.     }
  704.     public function setEveryInt(?int $everyInt): self
  705.     {
  706.         $this->everyInt = $everyInt;
  707.         return $this;
  708.     }
  709.     public function getEveryDateType(): ?string
  710.     {
  711.         return $this->everyDateType;
  712.     }
  713.     public function setEveryDateType(?string $everyDateType): self
  714.     {
  715.         $this->everyDateType = $everyDateType;
  716.         return $this;
  717.     }
  718.     public function getBikeAmount(): ?int
  719.     {
  720.         return $this->bikeAmount;
  721.     }
  722.     public function setBikeAmount(?int $bikeAmount): self
  723.     {
  724.         $this->bikeAmount = $bikeAmount;
  725.         return $this;
  726.     }
  727.     public function getRunAmount(): ?int
  728.     {
  729.         return $this->runAmount;
  730.     }
  731.     public function setRunAmount(?int $runAmount): self
  732.     {
  733.         $this->runAmount = $runAmount;
  734.         return $this;
  735.     }
  736.     public function getKinestexAmount(): ?int
  737.     {
  738.         return $this->kinestexAmount;
  739.     }
  740.     public function setKinestexAmount(?int $kinestexAmount): self
  741.     {
  742.         $this->kinestexAmount = $kinestexAmount;
  743.         return $this;
  744.     }
  745.     public function getKinestexPointsLow(): ?int
  746.     {
  747.         return $this->kinestexPointsLow;
  748.     }
  749.     public function setKinestexPointsLow(?int $kinestexPointsLow): self
  750.     {
  751.         $this->kinestexPointsLow = $kinestexPointsLow;
  752.         return $this;
  753.     }
  754.     public function getKinestexPointsMedium(): ?int
  755.     {
  756.         return $this->kinestexPointsMedium;
  757.     }
  758.     public function setKinestexPointsMedium(?int $kinestexPointsMedium): self
  759.     {
  760.         $this->kinestexPointsMedium = $kinestexPointsMedium;
  761.         return $this;
  762.     }
  763.     public function getKinestexPointsHigh(): ?int
  764.     {
  765.         return $this->kinestexPointsHigh;
  766.     }
  767.     public function setKinestexPointsHigh(?int $kinestexPointsHigh): self
  768.     {
  769.         $this->kinestexPointsHigh = $kinestexPointsHigh;
  770.         return $this;
  771.     }
  772.     public function getKinestexExercise(): ?KinestexExercise
  773.     {
  774.         return $this->kinestexExercise;
  775.     }
  776.     public function setKinestexExercise(?KinestexExercise $kinestexExercise): self
  777.     {
  778.         $this->kinestexExercise = $kinestexExercise;
  779.         return $this;
  780.     }
  781.     public function getKinestexRepetitions(): ?int
  782.     {
  783.         return $this->kinestexRepetitions;
  784.     }
  785.     public function setKinestexRepetitions(?int $kinestexRepetitions): self
  786.     {
  787.         $this->kinestexRepetitions = $kinestexRepetitions;
  788.         return $this;
  789.     }
  790.     public function getKinestexDuration(): ?int
  791.     {
  792.         return $this->kinestexDuration;
  793.     }
  794.     public function setKinestexDuration(?int $kinestexDuration): self
  795.     {
  796.         $this->kinestexDuration = $kinestexDuration;
  797.         return $this;
  798.     }
  799.     public function getDailyRewardPoints(): ?int
  800.     {
  801.         return $this->dailyRewardPoints;
  802.     }
  803.     public function setDailyRewardPoints(?int $dailyRewardPoints): self
  804.     {
  805.         $this->dailyRewardPoints = $dailyRewardPoints;
  806.         return $this;
  807.     }
  808.     public function getNotificationBaseTime(): ?string
  809.     {
  810.         return $this->notificationBaseTime;
  811.     }
  812.     public function setNotificationBaseTime(?string $notificationBaseTime): self
  813.     {
  814.         $this->notificationBaseTime = $notificationBaseTime;
  815.         return $this;
  816.     }
  817.     public function getNotificationMaxOffset(): ?int
  818.     {
  819.         return $this->notificationMaxOffset;
  820.     }
  821.     public function setNotificationMaxOffset(?int $notificationMaxOffset): self
  822.     {
  823.         $this->notificationMaxOffset = $notificationMaxOffset;
  824.         return $this;
  825.     }
  826. }