src/Entity/TeamUser.php line 64

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\OrderFilter;
  7. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  8. use ApiPlatform\Core\Serializer\Filter\GroupFilter;
  9. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  10. use App\Repository\TeamUserRepository;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Gedmo\Mapping\Annotation as Gedmo;
  13. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  14. use Symfony\Component\HttpFoundation\File\UploadedFile;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. /**
  18.  * @ORM\Entity(repositoryClass=TeamUserRepository::class)
  19.  * @ApiResource(
  20.  *      normalizationContext={
  21.  *          "groups"={"team_user:read"}
  22.  *      },
  23.  *      denormalizationContext={
  24.  *          "groups"={"team_user:write"}
  25.  *      },
  26.  *      itemOperations={
  27.  *          "get"={
  28.  *              "security"="is_granted('ROLE_USER')",
  29.  *          }, 
  30.  *          "patch"={
  31.  *              "security"="is_granted('ROLE_USER')",
  32.  *          }, 
  33.  *          "delete"={
  34.  *              "security"="is_granted('ROLE_USER')",
  35.  *          }
  36.  *      },
  37.  *      collectionOperations={
  38.  *          "get"={
  39.  *              "security"="is_granted('ROLE_USER')",
  40.  *          }, 
  41.  *          "post"={
  42.  *              "security"="is_granted('ROLE_USER')",
  43.  *          }
  44.  *      }
  45.  * )
  46.  * @ApiFilter(SearchFilter::class, properties={"user.id", "team.id", "teamplay.id", "type", "pseudo"})
  47.  * @ApiFilter(OrderFilter::class)
  48.  * @ApiFilter(PropertyFilter::class, 
  49.  *      arguments={
  50.  *          "parameterName"="fields", 
  51.  *          "overrideDefaultProperties"=true
  52.  *     }
  53.  * )
  54.  * @UniqueEntity(
  55.  *     fields={"user", "team"},
  56.  *     errorPath="team",
  57.  *     message="team.user_already_in_team",
  58.  *     ignoreNull=false
  59.  * )
  60.  */
  61. class TeamUser
  62. {
  63.     /**
  64.      * @ORM\Id
  65.      * @ORM\GeneratedValue
  66.      * @ORM\Column(type="integer")
  67.      * @Groups({"team_user:read", "team:read"})
  68.      */
  69.     private $id;
  70.     /**
  71.      * @ORM\ManyToOne(targetEntity=Team::class, inversedBy="teamUsers", cascade={"persist", "refresh"} )
  72.      * @ORM\JoinColumn(nullable=false)
  73.      * @Groups({"team_user:read", "team_user:write"})
  74.      */
  75.     private $team;
  76.     /**
  77.      * @ORM\Column(type="string", length=255, nullable=true)
  78.      * @Groups({"team_user:read"})
  79.      */
  80.     private $type;
  81.     /**
  82.      * @ORM\ManyToOne(targetEntity=TvUser::class, inversedBy="teamUsers")
  83.      * @ORM\JoinColumn(nullable=true)
  84.      */
  85.     private $tvUser;
  86.     /**
  87.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="teamUsers")
  88.      * @ORM\JoinColumn(nullable=true)
  89.      * @Assert\NotNull
  90.      * @Groups({"team_user:read", "team_user:write", "team:read"})
  91.      */
  92.     private $user;
  93.     /**
  94.      * @ORM\Column(type="string", length=255, nullable=true)
  95.      * @Groups({"team_user:read", "team_user:write", "team:read"})
  96.      */
  97.     private $pseudo;
  98.     /**
  99.      * @ORM\ManyToOne(targetEntity=Teamplay::class, inversedBy="teams", cascade={"refresh"})
  100.      * @Groups({"team_user:read", "team_user:write", "team_user:read:teamplay", "team:read"})
  101.      */
  102.     private $teamplay;
  103.     /**
  104.      * @ORM\Column(type="integer", nullable=true)
  105.      * @Groups({"team_user:read", "team_user:read:points", "team:read"})
  106.      */
  107.     private $points;
  108.     /**
  109.      * @ORM\Column(name="`rank`", type="integer", nullable=true)
  110.      * @Groups({"team_user:read", "team_user:read:rank", "team:read"})
  111.      */
  112.     private $rank null;
  113.     /**
  114.      * @ORM\Column(type="integer", nullable=true)
  115.      * @Groups({"team_user:read", "team_user:read:globalRank", "team:read"})
  116.      */
  117.     private $globalRank null;
  118.     /**
  119.      * @ORM\Column(type="datetime")
  120.      * @Gedmo\Timestampable(on="create")
  121.      * @Groups({"team_user:read"})
  122.      */
  123.     private $createdAt;
  124.     /**
  125.      * @ORM\Column(type="datetime")
  126.      * @Gedmo\Timestampable(on="update")
  127.      * @Groups({"team_user:read"})
  128.      */
  129.     private $updatedAt;
  130.     /**
  131.      * Custom field
  132.      * Nombre de pas effectuer depuis que le teamUser existe et durant le Teamplay
  133.      * @Groups({"team_user:read"})
  134.      */
  135.     public $stepAmount 0;
  136.     /**
  137.      * Custom field
  138.      * Quiz : Nombre de bonne rĂ©ponse durant le Teamplay
  139.      * @Groups({"team_user:read"})
  140.      */
  141.     public $quizAskedSuccessCount;
  142.     /**
  143.      * Custom field
  144.      * @var ?Chat
  145.      * @Groups({"team_user:read", "team_user:read:chat"})
  146.      */
  147.     public $chat;
  148.     public function getId(): ?int
  149.     {
  150.         return $this->id;
  151.     }
  152.     public function getTeam(): ?Team
  153.     {
  154.         return $this->team;
  155.     }
  156.     public function setTeam(?Team $team): self
  157.     {
  158.         $this->team $team;
  159.         return $this;
  160.     }
  161.     public function getType(): ?string
  162.     {
  163.         return $this->type;
  164.     }
  165.     public function setType(?string $type): self
  166.     {
  167.         $this->type $type;
  168.         return $this;
  169.     }
  170.     public function getTvUser(): ?TvUser
  171.     {
  172.         return $this->tvUser;
  173.     }
  174.     public function setTvUser(?TvUser $tvUser): self
  175.     {
  176.         $this->tvUser $tvUser;
  177.         return $this;
  178.     }
  179.     public function getUser(): ?User
  180.     {
  181.         return $this->user;
  182.     }
  183.     public function setUser(?User $user): self
  184.     {
  185.         $this->user $user;
  186.         return $this;
  187.     }
  188.     public function getPseudo(): ?string
  189.     {
  190.         return $this->pseudo;
  191.     }
  192.     public function setPseudo(?string $pseudo): self
  193.     {
  194.         $this->pseudo $pseudo;
  195.         return $this;
  196.     }
  197.     public function getTeamplay(): ?Teamplay
  198.     {
  199.         return $this->teamplay;
  200.     }
  201.     public function setTeamplay(?Teamplay $teamplay): self
  202.     {
  203.         $this->teamplay $teamplay;
  204.         return $this;
  205.     }
  206.     public function getPoints(): ?int
  207.     {
  208.         return $this->points;
  209.     }
  210.     public function setPoints(?int $points): self
  211.     {
  212.         $this->points $points;
  213.         return $this;
  214.     }
  215.     public function getRank(): ?int
  216.     {
  217.         return $this->rank;
  218.     }
  219.     public function setRank(?int $rank): self
  220.     {
  221.         $this->rank $rank;
  222.         return $this;
  223.     }
  224.     public function getGlobalRank(): ?int
  225.     {
  226.         return $this->globalRank;
  227.     }
  228.     public function setGlobalRank(?int $globalRank): self
  229.     {
  230.         $this->globalRank $globalRank;
  231.         return $this;
  232.     }
  233.     public function getCreatedAt(): ?\DateTimeInterface
  234.     {
  235.         return $this->createdAt;
  236.     }
  237.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  238.     {
  239.         $this->createdAt $createdAt;
  240.         return $this;
  241.     }
  242.     public function getUpdatedAt(): ?\DateTimeInterface
  243.     {
  244.         return $this->updatedAt;
  245.     }
  246.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  247.     {
  248.         $this->updatedAt $updatedAt;
  249.         return $this;
  250.     }
  251. }