src/Entity/User.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Security\Core\User\UserInterface;
  6. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  7. #[ORM\Entity(repositoryClassUserRepository::class)]
  8. class User implements UserInterfacePasswordAuthenticatedUserInterface
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255uniquetrue)]
  15.     private ?string $username null;
  16.     #[ORM\Column(length255nullabletrue)]
  17.     private ?string $email null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $password null;
  20.     #[ORM\ManyToOne]
  21.     #[ORM\JoinColumn(nullablefalse)]
  22.     private ?Role $role null;
  23.     // === NUEVOS BOOLEANOS ===
  24.     #[ORM\Column(type'boolean'options: ['default' => false])]
  25.     private bool $crearProyecto false;
  26.     #[ORM\Column(type'boolean'options: ['default' => false])]
  27.     private bool $mailNotificaciones false;
  28.     // ============================================================
  29.     // ðŸ”¹ Métodos base
  30.     // ============================================================
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getUsername(): ?string
  36.     {
  37.         return $this->username;
  38.     }
  39.     public function setUsername(string $username): static
  40.     {
  41.         $this->username $username;
  42.         return $this;
  43.     }
  44.     public function getEmail(): ?string
  45.     {
  46.         return $this->email;
  47.     }
  48.     public function setEmail(?string $email): static
  49.     {
  50.         $this->email $email;
  51.         return $this;
  52.     }
  53.     public function getPassword(): ?string
  54.     {
  55.         return $this->password;
  56.     }
  57.     public function setPassword(string $password): static
  58.     {
  59.         $this->password $password;
  60.         return $this;
  61.     }
  62.     public function getRole(): ?Role
  63.     {
  64.         return $this->role;
  65.     }
  66.     public function setRole(?Role $role): static
  67.     {
  68.         $this->role $role;
  69.         return $this;
  70.     }
  71.     public function getCrearProyecto(): bool
  72.     {
  73.         return $this->crearProyecto;
  74.     }
  75.     public function setCrearProyecto(bool $crearProyecto): static
  76.     {
  77.         $this->crearProyecto $crearProyecto;
  78.         return $this;
  79.     }
  80.     public function getMailNotificaciones(): bool
  81.     {
  82.         return $this->mailNotificaciones;
  83.     }
  84.     public function setMailNotificaciones(bool $mailNotificaciones): static
  85.     {
  86.         $this->mailNotificaciones $mailNotificaciones;
  87.         return $this;
  88.     }
  89.     // ============================================================
  90.     // ðŸ”’ Métodos requeridos por UserInterface
  91.     // ============================================================
  92. public function __toString(): string
  93. {
  94.     return $this->username ?? ''// o usa otro campo, como $this->email o $this->nombreCompleto
  95. }
  96.     public function getUserIdentifier(): string
  97.     {
  98.         return (string) $this->username;
  99.     }
  100.     public function getRoles(): array
  101.     {
  102.         return [$this->role $this->role->getName() : 'ROLE_USER'];
  103.     }
  104.     public function eraseCredentials(): void {}
  105.     public function getSalt(): ?string
  106.     {
  107.         return null;
  108.     }
  109. }