src/Entity/User.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  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(repositoryClassUserRepository::class)]
  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]
  16.     #[ORM\Column(type'integer')]
  17.     private $id;
  18.     #[ORM\Column(type'string'length180uniquetrue)]
  19.     private $email;
  20.     #[ORM\Column(type'json')]
  21.     private $roles = [];
  22.     #[ORM\Column(type'string')]
  23.     private $password;
  24.     private $plainPassword;
  25.     #[ORM\Column(type'string'length255nullabletrue)]
  26.     private $imie;
  27.     #[ORM\Column(type'string'length255nullabletrue)]
  28.     private $nazwisko;
  29.   
  30.     
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getEmail(): ?string
  36.     {
  37.         return $this->email;
  38.     }
  39.     public function setEmail(string $email): self
  40.     {
  41.         $this->email $email;
  42.         return $this;
  43.     }
  44.     /**
  45.      * A visual identifier that represents this user.
  46.      *
  47.      * @see UserInterface
  48.      */
  49.     public function getUserIdentifier(): string
  50.     {
  51.         return (string) $this->email;
  52.     }
  53.     /**
  54.      * @see UserInterface
  55.      */
  56.     public function getRoles(): array
  57.     {
  58.         $roles $this->roles;
  59.         // guarantee every user at least has ROLE_USER
  60.         $roles[] = 'ROLE_USER';
  61.         return array_unique($roles);
  62.     }
  63.     public function setRoles(array $roles): self
  64.     {
  65.         $this->roles $roles;
  66.         return $this;
  67.     }
  68.     /**
  69.      * @see PasswordAuthenticatedUserInterface
  70.      */
  71.     public function getPassword(): string
  72.     {
  73.         return $this->password;
  74.     }
  75.     public function setPassword(string $password): self
  76.     {
  77.         $this->password $password;
  78.         return $this;
  79.     }
  80.     /**
  81.      * @see UserInterface
  82.      */
  83.     public function eraseCredentials()
  84.     {
  85.         // If you store any temporary, sensitive data on the user, clear it here
  86.         // $this->plainPassword = null;
  87.     }
  88.     public function __toString(): string
  89.     {
  90.         if ($this->imie && $this->nazwisko) {
  91.             return $this->imie ' ' $this->nazwisko;
  92.         }
  93.         return $this->email;
  94.     }
  95.     public function getPlainPassword(): ?string
  96.     {
  97.         return $this->plainPassword;
  98.     }
  99.     public function setPlainPassword(?string $plainPassword): self
  100.     {
  101.         $this->plainPassword $plainPassword;
  102.         return $this;
  103.     }
  104.    
  105.     public function getImie(): ?string
  106.     {
  107.         return $this->imie;
  108.     }
  109.     public function setImie(?string $imie): self
  110.     {
  111.         $this->imie $imie;
  112.         return $this;
  113.     }
  114.     public function getNazwisko(): ?string
  115.     {
  116.         return $this->nazwisko;
  117.     }
  118.     public function setNazwisko(?string $nazwisko): self
  119.     {
  120.         $this->nazwisko $nazwisko;
  121.         return $this;
  122.     }
  123. }