src/Entity/User.php line 27
<?phpnamespace App\Entity;use App\Repository\UserRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;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 Symfony\Component\HttpFoundation\File\File;use Vich\UploaderBundle\Mapping\Annotation as Vich;use Scheb\TwoFactorBundle\Model\Totp\TotpConfiguration;use Scheb\TwoFactorBundle\Model\Totp\TotpConfigurationInterface;use Scheb\TwoFactorBundle\Model\Totp\TwoFactorInterface;use Symfony\Component\Validator\Constraints as Assert;#[ORM\Entity(repositoryClass: UserRepository::class)]#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]#[Vich\Uploadable]class User implements UserInterface, PasswordAuthenticatedUserInterface{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 180, unique: true)]private ?string $email = null;#[ORM\Column]private array $roles = [];/*** @var string The hashed password*/#[ORM\Column(nullable: true)]#[Assert\Length(min: 8, minMessage: "Le mot de passe doit faire au moins 8 caractères")]private ?string $password = null;#[ORM\Column(length: 100)]private ?string $firstname = null;#[ORM\Column(length: 100, nullable: true)]private ?string $lastname = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $CreatedAt = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $UpdatedAt = null;#[ORM\Column(nullable: true)]private ?bool $Enable = null;#[ORM\Column(length: 5, nullable: true)]private ?string $language = null;#[ORM\Column(nullable: true)]private ?bool $isVerified = null;#[ORM\ManyToOne(inversedBy: 'users')]private ?LawOffice $LawOffice = null;// NOTE: This is not a mapped field of entity metadata, just a simple property.#[Vich\UploadableField(mapping: 'user_avatar', fileNameProperty: 'avatarName', size: 'avatarSize')]private ?File $avatarFile = null;#[ORM\Column(nullable: true)]private ?string $avatarName = null;#[ORM\Column(nullable: true)]private ?int $avatarSize = null;#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: Client::class)]private Collection $clients;#[ORM\OneToMany(mappedBy: 'CreatedBy', targetEntity: TheCase::class)]private Collection $theCases;#[ORM\OneToMany(mappedBy: 'CreatedBy', targetEntity: Files::class)]private Collection $files;#[ORM\Column(nullable: true)]private ?string $totpSecret;public function __construct(){$this->clients = new ArrayCollection();$this->theCases = new ArrayCollection();$this->files = new ArrayCollection();}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;}/*** @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;}/*** @see UserInterface*/public function eraseCredentials(){// If you store any temporary, sensitive data on the user, clear it here// $this->plainPassword = null;}public function getFirstname(): ?string{return $this->firstname;}public function setFirstname(string $firstname): self{$this->firstname = $firstname;return $this;}public function getLastname(): ?string{return $this->lastname;}public function setLastname(?string $lastname): self{$this->lastname = $lastname;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;}public function isEnable(): ?bool{return $this->Enable;}public function setEnable(?bool $Enable): self{$this->Enable = $Enable;return $this;}public function getLanguage(): ?string{return $this->language;}public function setLanguage(?string $language): self{$this->language = $language;return $this;}public function isIsVerified(): ?bool{return $this->isVerified;}public function setIsVerified(?bool $isVerified): self{$this->isVerified = $isVerified;return $this;}public function isVerified(): bool{return $this->isVerified;}public function getLawOffice(): ?LawOffice{return $this->LawOffice;}public function setLawOffice(?LawOffice $LawOffice): self{$this->LawOffice = $LawOffice;return $this;}/*** If manually uploading a file (i.e. not using Symfony Form) ensure an instance* of 'UploadedFile' is injected into this setter to trigger the update. If this* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter* must be able to accept an instance of 'File' as the bundle will inject one here* during Doctrine hydration.** @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $avatarFile*/public function setAvatarFile(?File $avatarFile = null): void{$this->avatarFile = $avatarFile;if (null !== $avatarFile) {// It is required that at least one field changes if you are using doctrine// otherwise the event listeners won't be called and the file is lost$this->updatedAt = new \DateTimeImmutable();}}public function getAvatarFile(): ?File{return $this->avatarFile;}public function setAvatarName(?string $avatarName): void{$this->avatarName = $avatarName;}public function getAvatarName(): ?string{return $this->avatarName;}public function setAvatarSize(?int $avatarSize): void{$this->avatarSize = $avatarSize;}public function getAvatarSize(): ?int{return $this->avatarSize;}/*** @return Collection<int, Client>*/public function getClients(): Collection{return $this->clients;}public function addClient(Client $client): self{if (!$this->clients->contains($client)) {$this->clients->add($client);$client->setCreatedBy($this);}return $this;}public function removeClient(Client $client): self{if ($this->clients->removeElement($client)) {// set the owning side to null (unless already changed)if ($client->getCreatedBy() === $this) {$client->setCreatedBy(null);}}return $this;}/*** @return Collection<int, TheCase>*/public function getTheCases(): Collection{return $this->theCases;}public function addTheCase(TheCase $theCase): self{if (!$this->theCases->contains($theCase)) {$this->theCases->add($theCase);$theCase->setCreatedBy($this);}return $this;}public function removeTheCase(TheCase $theCase): self{if ($this->theCases->removeElement($theCase)) {// set the owning side to null (unless already changed)if ($theCase->getCreatedBy() === $this) {$theCase->setCreatedBy(null);}}return $this;}/*** @return Collection<int, Files>*/public function getFiles(): Collection{return $this->files;}public function addFile(Files $file): self{if (!$this->files->contains($file)) {$this->files->add($file);$file->setCreatedBy($this);}return $this;}public function removeFile(Files $file): self{if ($this->files->removeElement($file)) {// set the owning side to null (unless already changed)if ($file->getCreatedBy() === $this) {$file->setCreatedBy(null);}}return $this;}public function isTotpAuthenticationEnabled(): bool{return $this->totpSecret ? true : false;}public function getTotpAuthenticationUsername(): string{return $this->email;}public function getTotpAuthenticationConfiguration(): ?TotpConfigurationInterface{// You could persist the other configuration options in the user entity to make it individual per user.return new TotpConfiguration($this->totpSecret, TotpConfiguration::ALGORITHM_SHA1, 20, 8);}}