src/Entity/User.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity(repositoryClassUserRepository::class)]
  10. #[ORM\Table(name'`user`')]
  11. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  12. class User implements UserInterfacePasswordAuthenticatedUserInterface
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  16.     #[ORM\Column(type'integer')]
  17.     private int $id;
  18.     #[Assert\Email(
  19.         message'The email {{ value }} is not a valid email.',
  20.     )]
  21.     #[ORM\Column(length180uniquetrue)]
  22.     private string $email;
  23.     #[ORM\Column]
  24.     private array $roles = [];
  25.     /**
  26.      * @var string The hashed password
  27.      */
  28.     #[ORM\Column]
  29.     private string $password;
  30.     #[ORM\Column(length255)]
  31.     private ?string $firstname null;
  32.     #[ORM\Column(length255)]
  33.     private ?string $lastname null;
  34.     #[ORM\Column(length255nullabletrue)]
  35.     private ?string $mainJobPlace null;
  36.     #[ORM\Column(length255nullabletrue)]
  37.     private ?string $educationalLevel null;
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     /**
  43.      * @param mixed $id
  44.      */
  45.     public function setId(int $id): void
  46.     {
  47.         $this->id $id;
  48.     }
  49.     public function getEmail(): ?string
  50.     {
  51.         return $this->email;
  52.     }
  53.     public function setEmail(string $email): self
  54.     {
  55.         $this->email $email;
  56.         return $this;
  57.     }
  58.     /**
  59.      * A visual identifier that represents this user.
  60.      *
  61.      * @see UserInterface
  62.      */
  63.     public function getUserIdentifier(): string
  64.     {
  65.         return (string) $this->email;
  66.     }
  67.     /**
  68.      * @see UserInterface
  69.      */
  70.     public function getRoles(): array
  71.     {
  72.         $roles $this->roles;
  73.         // guarantee every user at least has ROLE_USER
  74.         $roles[] = 'ROLE_USER';
  75.         return array_unique($roles);
  76.     }
  77.     public function setRoles(array $roles): self
  78.     {
  79.         $this->roles $roles;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @see PasswordAuthenticatedUserInterface
  84.      */
  85.     public function getPassword(): string
  86.     {
  87.         return $this->password;
  88.     }
  89.     public function setPassword(string $password): self
  90.     {
  91.         $this->password $password;
  92.         return $this;
  93.     }
  94.     /**
  95.      * @see UserInterface
  96.      */
  97.     public function eraseCredentials()
  98.     {
  99.         // If you store any temporary, sensitive data on the user, clear it here
  100.         // $this->plainPassword = null;
  101.     }
  102.     public function getFirstname(): ?string
  103.     {
  104.         return $this->firstname;
  105.     }
  106.     public function setFirstname(string $firstname): static
  107.     {
  108.         $this->firstname $firstname;
  109.         return $this;
  110.     }
  111.     public function getLastname(): ?string
  112.     {
  113.         return $this->lastname;
  114.     }
  115.     public function setLastname(string $lastname): static
  116.     {
  117.         $this->lastname $lastname;
  118.         return $this;
  119.     }
  120.     public function getmainJobPlace(): ?string
  121.     {
  122.         return $this->mainJobPlace;
  123.     }
  124.     public function setmainJobPlace(?string $mainJobPlace): static
  125.     {
  126.         $this->mainJobPlace $mainJobPlace;
  127.         return $this;
  128.     }
  129.     public function getEducationalLevel(): ?string
  130.     {
  131.         return $this->educationalLevel;
  132.     }
  133.     public function setEducationalLevel(?string $educationalLevel): static
  134.     {
  135.         $this->educationalLevel $educationalLevel;
  136.         return $this;
  137.     }
  138. }