src/Entity/User.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use DateTimeImmutable;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use JMS\Serializer\Annotation\Groups;
  11. use JMS\Serializer\Annotation\MaxDepth;
  12. use OpenApi\Attributes as OA;
  13. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  14. use Symfony\Component\Security\Core\User\UserInterface;
  15. use Symfony\Component\Uid\Uuid;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. #[ORM\Entity(repositoryClassUserRepository::class)]
  18. class User implements UserInterfacePasswordAuthenticatedUserInterface
  19. {
  20.     #[ORM\Id]
  21.     #[ORM\Column(type'integer'uniquetrue)]
  22.     #[ORM\GeneratedValue(strategy'AUTO')]
  23.     #[OA\Property(type'integer', readOnly: true)]
  24.     private ?int $id null;
  25.     #[ORM\Column(length180uniquetrue)]
  26.     #[OA\Property(type'string'maxLength180)]
  27.     #[Assert\NotBlank(groups: ['create''update'])]
  28.     #[Assert\Email(groups: ['create''update'])]
  29.     private ?string $email null;
  30.     #[ORM\Column]
  31.     private array $roles = [];
  32.     /**
  33.      * @var ?string The hashed password
  34.      */
  35.     #[ORM\Column]
  36.     private ?string $password null;
  37.     #[ORM\Column(length255nullabletrue)]
  38.     #[OA\Property(type'string')]
  39.     private ?string $name null;
  40.     #[ORM\Column(length255nullabletrue)]
  41.     #[OA\Property(type'string')]
  42.     private ?string $surname null;
  43.     #[ORM\Column(length255nullabletrue)]
  44.     #[OA\Property(type'string')]
  45.     private ?string $comment null;
  46.     #[ORM\Column]
  47.     #[Gedmo\Timestampable(on'create')]
  48.     private ?DateTimeImmutable $createdAt null;
  49.     #[ORM\Column]
  50.     #[Gedmo\Timestampable(on'update')]
  51.     private ?DateTimeImmutable $updatedAt null;
  52.     #[ORM\Column(type'boolean')]
  53.     #[OA\Property(type'boolean')]
  54.     private bool $enabled false;
  55.     public function __construct()
  56.     {
  57.     }
  58.     public function getId(): int
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getEmail(): ?string
  63.     {
  64.         return $this->email;
  65.     }
  66.     public function setEmail(string $email): self
  67.     {
  68.         $this->email $email;
  69.         return $this;
  70.     }
  71.     /**
  72.      * A visual identifier that represents this user.
  73.      *
  74.      * @see UserInterface
  75.      */
  76.     public function getUserIdentifier(): string
  77.     {
  78.         return (string)$this->email;
  79.     }
  80.     /**
  81.      * @see UserInterface
  82.      */
  83.     public function getRoles(): array
  84.     {
  85.         $roles $this->roles;
  86.         // guarantee every user at least has ROLE_USER
  87.         $roles[] = 'ROLE_USER';
  88.         return array_unique($roles);
  89.     }
  90.     public function setRoles(array $roles): self
  91.     {
  92.         $this->roles $roles;
  93.         return $this;
  94.     }
  95.     /**
  96.      * @see PasswordAuthenticatedUserInterface
  97.      */
  98.     public function getPassword(): string
  99.     {
  100.         return $this->password;
  101.     }
  102.     public function setPassword(string $password): self
  103.     {
  104.         $this->password $password;
  105.         return $this;
  106.     }
  107.     /**
  108.      * @see UserInterface
  109.      */
  110.     public function eraseCredentials()
  111.     {
  112.         // If you store any temporary, sensitive data on the user, clear it here
  113.     }
  114.     public function getName(): ?string
  115.     {
  116.         return $this->name;
  117.     }
  118.     public function setName(?string $name): self
  119.     {
  120.         $this->name $name;
  121.         return $this;
  122.     }
  123.     public function getSurname(): ?string
  124.     {
  125.         return $this->surname;
  126.     }
  127.     public function setSurname(?string $surname): self
  128.     {
  129.         $this->surname $surname;
  130.         return $this;
  131.     }
  132.     public function getFullname(): ?string
  133.     {
  134.         return $this->surname ' ' $this->name;
  135.     }
  136.     public function getCreatedAt(): ?DateTimeImmutable
  137.     {
  138.         return $this->createdAt;
  139.     }
  140.     public function setCreatedAt(DateTimeImmutable $createdAt): self
  141.     {
  142.         $this->createdAt $createdAt;
  143.         return $this;
  144.     }
  145.     public function getUpdatedAt(): ?DateTimeImmutable
  146.     {
  147.         return $this->updatedAt;
  148.     }
  149.     public function setUpdatedAt(DateTimeImmutable $updatedAt): self
  150.     {
  151.         $this->updatedAt $updatedAt;
  152.         return $this;
  153.     }
  154.     /**
  155.      * @return string|null
  156.      */
  157.     public function getComment(): ?string
  158.     {
  159.         return $this->comment;
  160.     }
  161.     /**
  162.      * @param string|null $comment
  163.      */
  164.     public function setComment(?string $comment): void
  165.     {
  166.         $this->comment $comment;
  167.     }
  168.     /**
  169.      * @return bool
  170.      */
  171.     public function isEnabled(): bool
  172.     {
  173.         return $this->enabled;
  174.     }
  175.     /**
  176.      * @param bool $enabled
  177.      */
  178.     public function setEnabled(bool $enabled): void
  179.     {
  180.         $this->enabled $enabled;
  181.     }
  182. }