src/Domains/User/Domain/Entity/User.php line 14

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Domains\User\Domain\Entity;
  4. use App\Domains\User\Infrastructure\Repository\UserRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. #[ORM\Entity(repositoryClassUserRepository::class)]
  9. #[ORM\Table(name'`user`')]
  10. class User implements UserInterfacePasswordAuthenticatedUserInterface
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length180uniquetrue)]
  17.     private string $email;
  18.     #[ORM\Column]
  19.     private array $roles;
  20.     #[ORM\Column]
  21.     private string $password;
  22.     #[ORM\Column(length255)]
  23.     private string $firstName;
  24.     #[ORM\Column(length255)]
  25.     private string $lastName;
  26.     #[ORM\Column(length50nullabletrue)]
  27.     private ?string $status;
  28.     #[ORM\Column(length255nullabletrue)]
  29.     private ?string $googleId null;
  30.     public function __construct(
  31.         string $email,
  32.         string $password,
  33.         string $firstName,
  34.         string $lastName,
  35.         array $roles = ['ROLE_USER'],
  36.         ?string $status null
  37.     ) {
  38.         $this->email $email;
  39.         $this->password $password;
  40.         $this->firstName $firstName;
  41.         $this->lastName $lastName;
  42.         $this->roles $roles;
  43.         $this->status $status;
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getEmail(): string
  50.     {
  51.         return $this->email;
  52.     }
  53.     public function getFirstName(): string
  54.     {
  55.         return $this->firstName;
  56.     }
  57.     public function getLastName(): string
  58.     {
  59.         return $this->lastName;
  60.     }
  61.     public function getStatus(): ?string
  62.     {
  63.         return $this->status;
  64.     }
  65.     public function getGoogleId(): ?string
  66.     {
  67.         return $this->googleId;
  68.     }
  69.     public function setFirstName(string $firstName): void
  70.     {
  71.         $this->firstName $firstName;
  72.     }
  73.     public function setLastName(string $lastName): void
  74.     {
  75.         $this->lastName $lastName;
  76.     }
  77.     public function setGoogleId(string $googleId): void
  78.     {
  79.         $this->googleId $googleId;
  80.     }
  81.     public function getUserIdentifier(): string
  82.     {
  83.         return $this->email;
  84.     }
  85.     public function getRoles(): array
  86.     {
  87.         $roles $this->roles;
  88.         $roles[] = 'ROLE_USER';
  89.         return array_unique($roles);
  90.     }
  91.     public function getPassword(): string
  92.     {
  93.         return $this->password;
  94.     }
  95.     public function eraseCredentials(): void
  96.     {
  97.         // Clear any sensitive temporary data here, if needed
  98.     }
  99. }