src/Entity/User.php line 16

  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\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  10. use Symfony\Component\Security\Core\User\UserInterface;
  11. #[ORM\Entity(repositoryClass: UserRepository::class)]
  12. #[UniqueEntity(fields: ['email'], message: 'Ya existe una cuenta con este correo electronico')]
  13. class User implements UserInterface, PasswordAuthenticatedUserInterface
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id = null;
  19.     #[ORM\Column(length: 180, unique: true)]
  20.     private ?string $email = null;
  21.     #[ORM\Column]
  22.     private array $roles = [];
  23.     /**
  24.      * @var string The hashed password
  25.      */
  26.     #[ORM\Column]
  27.     private ?string $password = null;
  28.     #[ORM\Column(length: 255)]
  29.     private ?string $name = null;
  30.     #[ORM\Column(length: 255)]
  31.     private ?string $lastname = null;
  32.     #[ORM\Column(length: 255)]
  33.     private ?string $collegiateNumber = null;
  34.     #[ORM\ManyToOne(inversedBy: 'users')]
  35.     private ?Organization $organization = null;
  36.     #[ORM\Column(nullable: true)]
  37.     private ?bool $isAccepted1 = null;
  38.     #[ORM\Column(nullable: true)]
  39.     private ?bool $isAccepted2 = null;
  40.     #[ORM\Column(nullable: true)]
  41.     private ?bool $isAccepted3 = null;
  42.     #[ORM\Column(length: 255)]
  43.     private ?string $specialty = null;
  44.     #[ORM\Column]
  45.     private ?\DateTimeImmutable $createdAt = null;
  46.     #[ORM\Column]
  47.     private ?\DateTimeImmutable $lastAccessAt = null;
  48.     public function __toString()
  49.     {
  50.         return $this->email;
  51.     }
  52.     
  53.     public function getId(): ?int
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getEmail(): ?string
  58.     {
  59.         return $this->email;
  60.     }
  61.     public function setEmail(string $email): self
  62.     {
  63.         $this->email = $email;
  64.         return $this;
  65.     }
  66.     /**
  67.      * A visual identifier that represents this user.
  68.      *
  69.      * @see UserInterface
  70.      */
  71.     public function getUserIdentifier(): string
  72.     {
  73.         return (string) $this->email;
  74.     }
  75.     /**
  76.      * @see UserInterface
  77.      */
  78.     public function getRoles(): array
  79.     {
  80.         $roles = $this->roles;
  81.         // guarantee every user at least has ROLE_USER
  82.         $roles[] = 'ROLE_USER';
  83.         return array_unique($roles);
  84.     }
  85.     public function setRoles(array $roles): self
  86.     {
  87.         $this->roles = $roles;
  88.         return $this;
  89.     }
  90.     /**
  91.      * @see PasswordAuthenticatedUserInterface
  92.      */
  93.     public function getPassword(): string
  94.     {
  95.         return $this->password;
  96.     }
  97.     public function setPassword(string $password): self
  98.     {
  99.         $this->password = $password;
  100.         return $this;
  101.     }
  102.     /**
  103.      * @see UserInterface
  104.      */
  105.     public function eraseCredentials()
  106.     {
  107.         // If you store any temporary, sensitive data on the user, clear it here
  108.         // $this->plainPassword = null;
  109.     }
  110.     public function getName(): ?string
  111.     {
  112.         return $this->name;
  113.     }
  114.     public function setName(string $name): self
  115.     {
  116.         $this->name = $name;
  117.         return $this;
  118.     }
  119.     public function getLastname(): ?string
  120.     {
  121.         return $this->lastname;
  122.     }
  123.     public function setLastname(string $lastname): self
  124.     {
  125.         $this->lastname = $lastname;
  126.         return $this;
  127.     }
  128.     public function getCollegiateNumber(): ?string
  129.     {
  130.         return $this->collegiateNumber;
  131.     }
  132.     public function setCollegiateNumber(string $collegiateNumber): self
  133.     {
  134.         $this->collegiateNumber = $collegiateNumber;
  135.         return $this;
  136.     }
  137.     public function getOrganization(): ?Organization
  138.     {
  139.         return $this->organization;
  140.     }
  141.     public function setOrganization(?Organization $organization): self
  142.     {
  143.         $this->organization = $organization;
  144.         return $this;
  145.     }
  146.     public function isIsAccepted1(): ?bool
  147.     {
  148.         return $this->isAccepted1;
  149.     }
  150.     public function setIsAccepted1(?bool $isAccepted1): self
  151.     {
  152.         $this->isAccepted1 = $isAccepted1;
  153.         return $this;
  154.     }
  155.     public function isIsAccepted2(): ?bool
  156.     {
  157.         return $this->isAccepted2;
  158.     }
  159.     public function setIsAccepted2(?bool $isAccepted2): self
  160.     {
  161.         $this->isAccepted2 = $isAccepted2;
  162.         return $this;
  163.     }
  164.     public function isIsAccepted3(): ?bool
  165.     {
  166.         return $this->isAccepted3;
  167.     }
  168.     public function setIsAccepted3(?bool $isAccepted3): self
  169.     {
  170.         $this->isAccepted3 = $isAccepted3;
  171.         return $this;
  172.     }
  173.     public function getSpecialty(): ?string
  174.     {
  175.         return $this->specialty;
  176.     }
  177.     public function setSpecialty(string $specialty): self
  178.     {
  179.         $this->specialty = $specialty;
  180.         return $this;
  181.     }
  182.     public function getCreatedAt(): ?\DateTimeImmutable
  183.     {
  184.         return $this->createdAt;
  185.     }
  186.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  187.     {
  188.         $this->createdAt = $createdAt;
  189.         return $this;
  190.     }
  191.     public function getLastAccessAt(): ?\DateTimeImmutable
  192.     {
  193.         return $this->lastAccessAt;
  194.     }
  195.     public function setLastAccessAt(\DateTimeImmutable $lastAccessAt): self
  196.     {
  197.         $this->lastAccessAt = $lastAccessAt;
  198.         return $this;
  199.     }
  200. }