<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @ORM\Column(type="integer")
*/
private $id_role;
/**
* @return mixed
*/
public function getIdRole()
{
return $this->id_role;
}
/**
* @param mixed $id_role
*/
public function setIdRole($id_role): void
{
$this->id_role = $id_role;
}
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $id_tiers;
/**
* @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
*/
private $date_crea;
/**
* @ORM\Column(type="integer")
*/
private $user_crea;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $date_modif;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $user_modif;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $password_requested_at;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $token;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $avatar_user;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private $theme_user;
/**
* @ORM\Column(type="boolean", options={"default": 1})
*/
private $is_active;
/**
* @ORM\OneToOne(targetEntity=Tiers::class, inversedBy="user", cascade={"persist", "remove"})
*/
private $tiers;
public function clearForJsonResp(){
$this->getTiers()->clearForJsonResp();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
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;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getIdTiers(): ?int
{
return $this->id_tiers;
}
public function setIdTiers(?int $id_tiers): self
{
$this->id_tiers = $id_tiers;
return $this;
}
public function getDateCrea(): ?\DateTimeInterface
{
return $this->date_crea;
}
public function setDateCrea(\DateTimeInterface $date_crea): self
{
$this->date_crea = $date_crea;
return $this;
}
public function getUserCrea(): ?int
{
return $this->user_crea;
}
public function setUserCrea(int $user_crea): self
{
$this->user_crea = $user_crea;
return $this;
}
public function getDateModif(): ?\DateTimeInterface
{
return $this->date_modif;
}
public function setDateModif(?\DateTimeInterface $date_modif): self
{
$this->date_modif = $date_modif;
return $this;
}
public function getUserModif(): ?int
{
return $this->user_modif;
}
public function setUserModif(?int $user_modif): self
{
$this->user_modif = $user_modif;
return $this;
}
public function getPasswordRequestedAt(): ?int
{
return $this->password_requested_at;
}
public function setPasswordRequestedAt(?int $password_requested_at): self
{
$this->password_requested_at = $password_requested_at;
return $this;
}
public function getToken(): ?string
{
return $this->token;
}
public function setToken(string $token): self
{
$this->token = $token;
return $this;
}
public function getAvatarUser(): ?string
{
return $this->avatar_user;
}
public function setAvatarUser(string $avatar_user): self
{
$this->avatar_user = $avatar_user;
return $this;
}
public function getThemeUser(): ?string
{
return $this->theme_user;
}
public function setThemeUser(?string $theme_user): self
{
$this->theme_user = $theme_user;
return $this;
}
public function getIsActive(): ?bool
{
return $this->is_active;
}
public function setIsActive(bool $is_active): self
{
$this->is_active = $is_active;
return $this;
}
public function getTiers(): ?Tiers
{
return $this->tiers;
}
public function setTiers(?Tiers $tiers): self
{
$this->tiers = $tiers;
return $this;
}
}