<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Serializer\Filter\GroupFilter;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use App\Repository\TeamUserRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=TeamUserRepository::class)
* @ApiResource(
* normalizationContext={
* "groups"={"team_user:read"}
* },
* denormalizationContext={
* "groups"={"team_user:write"}
* },
* itemOperations={
* "get"={
* "security"="is_granted('ROLE_USER')",
* },
* "patch"={
* "security"="is_granted('ROLE_USER')",
* },
* "delete"={
* "security"="is_granted('ROLE_USER')",
* }
* },
* collectionOperations={
* "get"={
* "security"="is_granted('ROLE_USER')",
* },
* "post"={
* "security"="is_granted('ROLE_USER')",
* }
* }
* )
* @ApiFilter(SearchFilter::class, properties={"user.id", "team.id", "teamplay.id", "type", "pseudo"})
* @ApiFilter(OrderFilter::class)
* @ApiFilter(PropertyFilter::class,
* arguments={
* "parameterName"="fields",
* "overrideDefaultProperties"=true
* }
* )
* @UniqueEntity(
* fields={"user", "team"},
* errorPath="team",
* message="team.user_already_in_team",
* ignoreNull=false
* )
*/
class TeamUser
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"team_user:read", "team:read"})
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Team::class, inversedBy="teamUsers", cascade={"persist", "refresh"} )
* @ORM\JoinColumn(nullable=false)
* @Groups({"team_user:read", "team_user:write"})
*/
private $team;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"team_user:read"})
*/
private $type;
/**
* @ORM\ManyToOne(targetEntity=TvUser::class, inversedBy="teamUsers")
* @ORM\JoinColumn(nullable=true)
*/
private $tvUser;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="teamUsers")
* @ORM\JoinColumn(nullable=true)
* @Assert\NotNull
* @Groups({"team_user:read", "team_user:write", "team:read"})
*/
private $user;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"team_user:read", "team_user:write", "team:read"})
*/
private $pseudo;
/**
* @ORM\ManyToOne(targetEntity=Teamplay::class, inversedBy="teams", cascade={"refresh"})
* @Groups({"team_user:read", "team_user:write", "team_user:read:teamplay", "team:read"})
*/
private $teamplay;
/**
* @ORM\Column(type="integer", nullable=true)
* @Groups({"team_user:read", "team_user:read:points", "team:read"})
*/
private $points;
/**
* @ORM\Column(name="`rank`", type="integer", nullable=true)
* @Groups({"team_user:read", "team_user:read:rank", "team:read"})
*/
private $rank = null;
/**
* @ORM\Column(type="integer", nullable=true)
* @Groups({"team_user:read", "team_user:read:globalRank", "team:read"})
*/
private $globalRank = null;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
* @Groups({"team_user:read"})
*/
private $createdAt;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="update")
* @Groups({"team_user:read"})
*/
private $updatedAt;
/**
* Custom field
* Nombre de pas effectuer depuis que le teamUser existe et durant le Teamplay
* @Groups({"team_user:read"})
*/
public $stepAmount = 0;
/**
* Custom field
* Quiz : Nombre de bonne réponse durant le Teamplay
* @Groups({"team_user:read"})
*/
public $quizAskedSuccessCount;
/**
* Custom field
* @var ?Chat
* @Groups({"team_user:read", "team_user:read:chat"})
*/
public $chat;
public function getId(): ?int
{
return $this->id;
}
public function getTeam(): ?Team
{
return $this->team;
}
public function setTeam(?Team $team): self
{
$this->team = $team;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getTvUser(): ?TvUser
{
return $this->tvUser;
}
public function setTvUser(?TvUser $tvUser): self
{
$this->tvUser = $tvUser;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getPseudo(): ?string
{
return $this->pseudo;
}
public function setPseudo(?string $pseudo): self
{
$this->pseudo = $pseudo;
return $this;
}
public function getTeamplay(): ?Teamplay
{
return $this->teamplay;
}
public function setTeamplay(?Teamplay $teamplay): self
{
$this->teamplay = $teamplay;
return $this;
}
public function getPoints(): ?int
{
return $this->points;
}
public function setPoints(?int $points): self
{
$this->points = $points;
return $this;
}
public function getRank(): ?int
{
return $this->rank;
}
public function setRank(?int $rank): self
{
$this->rank = $rank;
return $this;
}
public function getGlobalRank(): ?int
{
return $this->globalRank;
}
public function setGlobalRank(?int $globalRank): self
{
$this->globalRank = $globalRank;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
}