src/Entity/Users.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UsersRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. #[ORM\Entity(repositoryClassUsersRepository::class)]
  11. #[UniqueEntity(fields: ['email'], message'Cette adresse mail est déjà utilisé')]
  12. class Users implements UserInterfacePasswordAuthenticatedUserInterface
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private int $id;
  18.     #[ORM\Column(length20uniquetrue)]
  19.     private string $email;
  20.     #[ORM\Column]
  21.     private array $roles = [];
  22.     /**
  23.      * @var string The hashed password
  24.      */
  25.     #[ORM\Column(length255)]
  26.     private ?string $password null;
  27.     // #[ORM\Column(length: 200)]
  28.     // private ?string $pseudo = null;
  29.     #[ORM\Column(length100nullabletrue)]
  30.     private ?string $contact;
  31.     #[ORM\Column(length20)]
  32.     private ?string $fonction;
  33.     #[ORM\Column(length20)]
  34.     private ?string $nom;
  35.     #[ORM\Column(length10nullabletrue)]
  36.     private ?string $statut;
  37.     #[ORM\Column(length200nullabletrue)]
  38.     private ?string $image 'NO_FILE';
  39.     #[ORM\Column(length100nullabletrue)]
  40.     private string $role;
  41.     #[ORM\Column]
  42.     private ?\DateTimeImmutable $created_at null;
  43.     private ?string $plainpassword null;
  44.     public function __construct(){
  45.         $this->created_at = new \DateTimeImmutable();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getNom(): ?string
  52.     {
  53.         return $this->nom;
  54.     }
  55.     public function setNom(string $nom): static
  56.     {
  57.         $this->nom $nom;
  58.         return $this;
  59.     }
  60.     public function setPlainPassword(string $plainpassword): static
  61.     {
  62.         $this->plainpassword $plainpassword;
  63.         return $this;
  64.     }
  65.     
  66.     public function getPlainPassword(): ?string
  67.     {
  68.         return $this->plainpassword;
  69.     }
  70.     /**
  71.      * A visual identifier that represents this user.
  72.      *
  73.      * @see UserInterface
  74.      */
  75.     public function getUserIdentifier(): string
  76.     {
  77.         return (string) $this->email;
  78.     }
  79.     /**
  80.      * @see UserInterface
  81.      */
  82.     public function getRoles(): array
  83.     {
  84.         $roles $this->roles;
  85.         // guarantee every user at least has ROLE
  86.         $roles[] = 'ROLE_USER';
  87.         return array_unique($roles);
  88.     }
  89.     public function setRoles(array $roles): self
  90.     {
  91.         $this->roles $roles;
  92.         return $this;
  93.     }
  94.     /**
  95.      * @see PasswordAuthenticatedUserInterface
  96.      */
  97.     public function getPassword(): ?string
  98.     {
  99.         return $this->password;
  100.     }
  101.     public function setPassword(string $password): self
  102.     {
  103.         $this->password $password;
  104.         return $this;
  105.     }
  106.     /**
  107.      * @see UserInterface
  108.      */
  109.     public function eraseCredentials(): void
  110.     {
  111.         // If you store any temporary, sensitive data on the user, clear it here
  112.         // $this->plainPassword = null;
  113.     }
  114.     public function getFonction(): ?string
  115.     {
  116.         return $this->fonction;
  117.     }
  118.     public function setFonction(string $fonction): static
  119.     {
  120.         $this->fonction $fonction;
  121.         return $this;
  122.     }
  123.     public function getRole(): ?string
  124.     {
  125.         return $this->role;
  126.         // $role[] = 'USER, ADMIN';
  127.         //return array_unique($role);
  128.     }
  129.     public function setRole(string $role): static
  130.     {
  131.         $this->role $role;
  132.         return $this;
  133.     }
  134.     public function getContact(): ?string
  135.     {
  136.         return $this->contact;
  137.     }
  138.     public function setContact(string $contact): static
  139.     {
  140.         $this->contact $contact;
  141.         return $this;
  142.     }
  143.     public function getStatut(): ?string
  144.     {
  145.         return $this->statut;
  146.     }
  147.     public function setStatut(string $statut): static
  148.     {
  149.         $this->statut $statut;
  150.         return $this;
  151.     }
  152.     public function getEmail(): ?string
  153.     {
  154.         return $this->email;
  155.     }
  156.     public function setEmail(string $email): self
  157.     {
  158.         $this->email $email;
  159.         return $this;
  160.     }
  161.     public function getImage(): ?string
  162.     {
  163.         return $this->image;
  164.     }
  165.     public function setImage(string $image): static
  166.     {
  167.         $this->image $image;
  168.         return $this;
  169.     }
  170.     public function getCreatedAt(): ?\DateTimeImmutable
  171.     {
  172.         return $this->created_at;
  173.     }
  174.     public function setCreatedAt(\DateTimeImmutable $created_at): static
  175.     {
  176.         $this->created_at $created_at;
  177.         return $this;
  178.     }
  179. }