src/Entity/User.php line 17
<?phpnamespace App\Entity;use App\Repository\UserRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;use Symfony\Component\Security\Core\User\UserInterface;use Doctrine\DBAL\Types\Types;#[ORM\Entity(repositoryClass: UserRepository::class)]#[ORM\Table(name: '`user`')]#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]class User implements UserInterface, PasswordAuthenticatedUserInterface{const ROLE_ADMIN = 'ROLE_ADMIN';const ROLE_USER = 'ROLE_USER';const LOGIN_SOCIAL_NULL = 0;const LOGIN_SOCIAL_TWITTER = 1;const LOGIN_SOCIAL_GOOGLE = 2;const LOGIN_SOCIAL_FACEBOOK = 3;#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 180, unique: true)]private ?string $email = null;#[ORM\Column(length: 180, nullable: true)]private ?string $apelido = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $avatar = null;#[ORM\Column]private array $roles = [];/*** @var string The hashed password*/#[ORM\Column]private ?string $password = null;#[ORM\Column(type: 'boolean')]private $isVerified = false;#[ORM\OneToMany(mappedBy: 'Usuario', targetEntity: Token::class, orphanRemoval: true)]private Collection $tokens;#[ORM\ManyToOne(inversedBy: 'Usuarios', targetEntity: Perfil::class)]#[ORM\JoinColumn(nullable: true)]private ?Perfil $Perfil = null;#[ORM\Column(type: 'boolean')]private $isExpired = false;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $lastlogin = null;#[ORM\Column(type: Types::DATETIME_MUTABLE)]private ?\DateTimeInterface $created_at = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $updated_at = null;#[ORM\OneToMany(mappedBy: 'Usuario', targetEntity: JogosUsuario::class)]private Collection $JogosUsuarios;#[ORM\Column(nullable: true)]private ?float $saldo = null;#[ORM\OneToMany(mappedBy: 'User', targetEntity: Creditos::class)]private Collection $Creditos;#[ORM\OneToMany(mappedBy: 'User', targetEntity: Convites::class)]private Collection $Convites;#[ORM\OneToMany(mappedBy: 'UserEuConvidei', targetEntity: Conexoes::class)]private Collection $ConexoesConvidantes;#[ORM\OneToMany(mappedBy: 'Desafiador', targetEntity: Desafios::class)]private Collection $Desafiador;#[ORM\OneToMany(mappedBy: 'User', targetEntity: UserPalavras::class)]private Collection $UserPalavras;#[ORM\OneToMany(mappedBy: 'User', targetEntity: UserParametros::class)]private Collection $UserParametros;#[ORM\Column]private ?int $loginsocial = null;#[ORM\Column(length: 255)]private ?string $deviceId = null;#[ORM\Column(nullable: true)]private ?int $pontos = null;#[ORM\Column(nullable: true)]private ?array $configuracoes = null;#[ORM\Column(length: 255)]private ?string $tokenPush = null;#[ORM\Column(length: 255)]private ?string $tokenTipo = null;#[ORM\Column]private ?int $tentativaPush = null;public function __construct(){$this->tokens = new ArrayCollection();$this->JogosUsuarios = new ArrayCollection();$this->Creditos = new ArrayCollection();$this->Convites = new ArrayCollection();$this->ConexoesConvidantes = new ArrayCollection();$this->Desafiador = new ArrayCollection();$this->UserPalavras = new ArrayCollection();$this->UserParametros = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getPerfil(): ?Perfil{return $this->Perfil;}public function setPerfil(?Perfil $Perfil): self{$this->Perfil = $Perfil;return $this;}public function getEmail(): ?string{return $this->email;}public function setEmail(string $email): self{$this->email = $email;return $this;}public function getApelido(): ?string{return $this->apelido;}public function setApelido(string $apelido): self{$this->apelido = $apelido;return $this;}public function getAvatar(): ?string{return $this->avatar;}public function setAvatar(string $avatar): self{$this->avatar = $avatar;return $this;}/*** A visual identifier that represents this user.** @see UserInterface*/public function getUserIdentifier(): string{return (string) $this->email;}/*** @see UserInterface*/public function getRoles(): array{$roles = $this->roles;return array_unique($roles);}public function setRoles(array $roles): self{$this->roles = $roles;return $this;}/*** @see PasswordAuthenticatedUserInterface*/public function getPassword(): string{return $this->password;}public function setPassword(string $password): self{$this->password = $password;return $this;}/*** @see UserInterface*/public function eraseCredentials(){// If you store any temporary, sensitive data on the user, clear it here// $this->plainPassword = null;}public function isVerified(): bool{return $this->isVerified;}public function setIsVerified(bool $isVerified): self{$this->isVerified = $isVerified;return $this;}public function isExpired(): bool{return $this->isExpired;}public function setIsExpired(bool $isExpired): self{$this->isExpired = $isExpired;return $this;}/*** @return Collection<int, Token>*/public function getTokens(): Collection{return $this->tokens;}public function addToken(Token $token): self{if (!$this->tokens->contains($token)) {$this->tokens->add($token);$token->setUsuario($this);}return $this;}public function removeToken(Token $token): self{if ($this->tokens->removeElement($token)) {// set the owning side to null (unless already changed)if ($token->getUsuario() === $this) {$token->setUsuario(null);}}return $this;}public function getLastlogin(): ?\DateTimeInterface{return $this->lastlogin;}public function setLastlogin(\DateTimeInterface $lastlogin): self{$this->lastlogin = $lastlogin;return $this;}public function getCreatedAt(): ?\DateTimeInterface{return $this->created_at;}public function setCreatedAt(): self{$this->created_at = new \DateTime('now');return $this;}public function getUpdatedAt(): ?\DateTimeInterface{return $this->updated_at;}public function setUpdatedAt(): self{$this->updated_at = new \DateTime('now');return $this;}public function isAdmin(){return $this->checkRole(self::ROLE_ADMIN);}public function isUser(){return $this->checkRole(self::ROLE_USER);}private function checkRole($role){$filtered_array = [];if(is_array($this->getRoles())){$filtered_array = array_filter($this->getRoles(), function($value, $key) use ($role) {return $value == $role;}, ARRAY_FILTER_USE_BOTH);}return count($filtered_array) == 1;}/*** @return Collection<int, JogosUsuario>*/public function getJogosUsuarios(): Collection{return $this->JogosUsuarios;}public function addJogosUsuario(JogosUsuario $jogosUsuario): self{if (!$this->JogosUsuarios->contains($jogosUsuario)) {$this->JogosUsuarios->add($jogosUsuario);$jogosUsuario->setUsuario($this);}return $this;}public function removeJogosUsuario(JogosUsuario $jogosUsuario): self{if ($this->JogosUsuarios->removeElement($jogosUsuario)) {// set the owning side to null (unless already changed)if ($jogosUsuario->getUsuario() === $this) {$jogosUsuario->setUsuario(null);}}return $this;}public function getSaldo(): ?float{return $this->saldo;}public function setSaldo(?float $saldo): self{$this->saldo = $saldo;return $this;}/*** @return Collection<int, Creditos>*/public function getCreditos(): Collection{return $this->Creditos;}public function addCredito(Creditos $credito): self{if (!$this->Creditos->contains($credito)) {$this->Creditos->add($credito);$credito->setUser($this);}return $this;}public function removeCredito(Creditos $credito): self{if ($this->Creditos->removeElement($credito)) {// set the owning side to null (unless already changed)if ($credito->getUser() === $this) {$credito->setUser(null);}}return $this;}/*** @return Collection<int, Convites>*/public function getConvites(): Collection{return $this->Convites;}public function addConvite(Convites $convite): self{if (!$this->Convites->contains($convite)) {$this->Convites->add($convite);$convite->setUser($this);}return $this;}public function removeConvite(Convites $convite): self{if ($this->Convites->removeElement($convite)) {// set the owning side to null (unless already changed)if ($convite->getUser() === $this) {$convite->setUser(null);}}return $this;}/*** @return Collection<int, Conexoes>*/public function getConexoesConvidantes(): Collection{return $this->ConexoesConvidantes;}public function addConexoesConvidante(Conexoes $conexoesConvidante): self{if (!$this->ConexoesConvidantes->contains($conexoesConvidante)) {$this->ConexoesConvidantes->add($conexoesConvidante);$conexoesConvidante->setUserConvidante($this);}return $this;}public function removeConexoesConvidante(Conexoes $conexoesConvidante): self{if ($this->ConexoesConvidantes->removeElement($conexoesConvidante)) {// set the owning side to null (unless already changed)if ($conexoesConvidante->getUserConvidante() === $this) {$conexoesConvidante->setUserConvidante(null);}}return $this;}/*** @return Collection<int, Desafios>*/public function getDesafiador(): Collection{return $this->Desafiador;}public function addDesafiador(Desafios $Desafiador): self{if (!$this->Desafiador->contains($Desafiador)) {$this->Desafiador->add($Desafiador);$Desafiador->setUser($this);}return $this;}public function removeDesafiador(Desafios $Desafiador): self{if ($this->Desafiador->removeElement($Desafiador)) {// set the owning side to null (unless already changed)if ($Desafiador->getUser() === $this) {$Desafiador->setUser(null);}}return $this;}/*** @return Collection<int, UserPalavras>*/public function getUserPalavras(): Collection{return $this->UserPalavras;}public function addUserPalavra(UserPalavras $userPalavra): self{if (!$this->UserPalavras->contains($userPalavra)) {$this->UserPalavras->add($userPalavra);$userPalavra->setUser($this);}return $this;}public function removeUserPalavra(UserPalavras $userPalavra): self{if ($this->UserPalavras->removeElement($userPalavra)) {// set the owning side to null (unless already changed)if ($userPalavra->getUser() === $this) {$userPalavra->setUser(null);}}return $this;}/*** @return Collection<int, UserParametros>*/public function getUserParametros(): Collection{return $this->UserParametros;}public function addUserParametros(UserParametros $userParametros): self{if (!$this->UserParametros->contains($userParametros)) {$this->UserParametros->add($userParametros);$userParametros->setUser($this);}return $this;}public function removeUserParametros(UserParametros $userParametros): self{if ($this->UserParametros->removeElement($userParametros)) {// set the owning side to null (unless already changed)if ($userParametros->getUser() === $this) {$userParametros->setUser(null);}}return $this;}public function getLoginsocial(): ?int{return $this->loginsocial;}public function setLoginsocial(int $loginsocial): self{$this->loginsocial = $loginsocial;return $this;}public function getDeviceId(): ?string{return $this->deviceId;}public function setDeviceId(string $deviceId): self{$this->deviceId = $deviceId;return $this;}public function getPontos(): ?int{return $this->pontos;}public function setPontos(int $pontos): static{$this->pontos = $pontos;return $this;}public function getConfiguracoes(): ?array{return $this->configuracoes;}public function setConfiguracoes(?array $configuracoes): static{$this->configuracoes = $configuracoes;return $this;}public function getTokenPush(): ?string{return $this->tokenPush;}public function setTokenPush(string $tokenPush): static{$this->tokenPush = $tokenPush;return $this;}public function getTokenTipo(): ?string{return $this->tokenTipo;}public function setTokenTipo(string $tokenTipo): static{$this->tokenTipo = $tokenTipo;return $this;}public function getTentativaPush(): ?int{return $this->tentativaPush;}public function setTentativaPush(int $tentativaPush = 0): static{$this->tentativaPush = $tentativaPush;return $this;}}