hegresphere/src/Entity/UserApp.php

204 lines
4.2 KiB
PHP
Raw Normal View History

2024-10-03 17:23:33 +02:00
<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM;
2024-11-21 15:59:55 +01:00
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
2024-10-03 17:23:33 +02:00
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: UserRepository::class)]
2024-10-17 17:56:46 +02:00
#[ORM\Table(name: 'userApp')]
#[ORM\InheritanceType('JOINED')]
#[ORM\DiscriminatorColumn(name: 'DISCRIMINATOR', type: 'string')]
#[ORM\DiscriminatorMap(['employee' => Employee::class, 'intern' => Intern::class])]
2024-10-03 17:23:33 +02:00
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_NICKNAME', fields: ['nickname'])]
2024-11-21 15:59:55 +01:00
#[UniqueEntity(fields: ['nickname'], message: 'Il y a déjà un compte avec ces identifiants !')]
2024-10-17 17:56:46 +02:00
class UserApp implements UserInterface, PasswordAuthenticatedUserInterface
2024-10-03 17:23:33 +02:00
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180)]
private ?string $nickname = null;
/**
* @var list<string> The user roles
*/
2024-11-21 15:59:55 +01:00
#[ORM\Column]
2024-11-21 16:17:24 +01:00
private array $roles = [];
2024-10-03 17:23:33 +02:00
/**
* @var string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
2024-11-21 15:59:55 +01:00
#[ORM\Column(length: 255, nullable: true)]
2024-10-17 16:38:47 +02:00
private ?string $firstName = null;
2024-11-21 15:59:55 +01:00
#[ORM\Column(length: 255, nullable: true)]
2024-10-17 16:38:47 +02:00
private ?string $lastName = null;
2024-11-21 15:59:55 +01:00
#[ORM\Column(length: 255,nullable: true)]
2024-10-17 16:38:47 +02:00
private ?string $tel = null;
2024-11-21 15:59:55 +01:00
#[ORM\Column(length: 255,nullable: true)]
2024-10-17 16:38:47 +02:00
private ?string $address = null;
2024-11-21 15:59:55 +01:00
#[ORM\Column(length: 255,nullable: true)]
2024-10-10 14:47:52 +02:00
private ?string $mail = null;
2024-10-17 16:38:47 +02:00
2024-10-03 17:23:33 +02:00
public function getId(): ?int
{
return $this->id;
}
public function getNickname(): ?string
{
return $this->nickname;
}
public function setNickname(string $nickname): static
{
$this->nickname = $nickname;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->nickname;
}
/**
* @see UserInterface
*
* @return list<string>
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
/**
* @param list<string> $roles
*/
public function setRoles(array $roles): static
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): static
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function eraseCredentials(): void
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
2024-10-17 16:38:47 +02:00
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(string $firstName): static
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(string $lastName): static
{
$this->lastName = $lastName;
return $this;
}
public function getTel(): ?string
{
return $this->tel;
}
public function setTel(string $tel): static
{
$this->tel = $tel;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): static
{
$this->address = $address;
return $this;
}
2024-10-10 14:47:52 +02:00
public function getMail(): ?string
2024-10-17 16:38:47 +02:00
{
2024-10-10 14:47:52 +02:00
return $this->mail;
2024-10-17 16:38:47 +02:00
}
2024-10-10 14:47:52 +02:00
public function setMail(string $mail): static
2024-10-17 16:38:47 +02:00
{
2024-10-10 14:47:52 +02:00
$this->mail = $mail;
2024-10-17 16:38:47 +02:00
return $this;
}
2024-11-21 15:59:55 +01:00
public function isVerified(): bool
{
return $this->isVerified;
}
public function setVerified(bool $isVerified): static
{
$this->isVerified = $isVerified;
return $this;
}
2024-10-10 14:47:52 +02:00
}