['profile:read']], denormalizationContext: ['groups' => ['profile:write']] )] class Profile implements UserInterface, PasswordAuthenticatedUserInterface { #[ORM\Id] #[ORM\Column(type: 'string', length: 36)] #[Groups(['profile:read'])] private ?string $id = null; #[ORM\Column(type: 'string', length: 180, unique: true, nullable: true)] #[Assert\Email] #[Groups(['profile:read', 'profile:write'])] private ?string $email = null; #[ORM\Column(type: 'string', length: 100, name: 'firstname')] #[Assert\NotBlank] #[Groups(['profile:read', 'profile:write'])] private string $firstName; #[ORM\Column(type: 'string', length: 100, name: 'lastname')] #[Assert\NotBlank] #[Groups(['profile:read', 'profile:write'])] private string $lastName; #[ORM\Column(type: 'boolean', options: ['default' => true], name: 'isactive')] #[Groups(['profile:read', 'profile:write'])] private bool $isActive = true; /** * @var list The user roles */ #[ORM\Column(type: 'json', options: ['default' => '["ROLE_USER"]'])] #[Groups(['profile:read', 'profile:write'])] private array $roles = ['ROLE_USER']; /** * @var string The hashed password */ #[ORM\Column(type: 'string', nullable: true)] #[Groups(['profile:write'])] private ?string $password = null; #[ORM\Column(type: 'datetime_immutable', name: 'createdat')] #[Groups(['profile:read'])] private DateTimeImmutable $createdAt; #[ORM\Column(type: 'datetime_immutable', name: 'updatedat')] #[Groups(['profile:read'])] private DateTimeImmutable $updatedAt; public function __construct() { // Générer un CUID-like ID pour compatibilité avec Prisma $this->id = 'cl'.substr(strtolower(base_convert(random_bytes(12), 2, 36)), 0, 24); $this->createdAt = new DateTimeImmutable(); $this->updatedAt = new DateTimeImmutable(); } public function getId(): ?string { return $this->id; } public function getEmail(): ?string { return $this->email; } public function setEmail(?string $email): static { $this->email = $email; return $this; } public function getFirstName(): string { return $this->firstName; } public function setFirstName(string $firstName): static { $this->firstName = $firstName; return $this; } public function getLastName(): string { return $this->lastName; } public function setLastName(string $lastName): static { $this->lastName = $lastName; return $this; } public function isActive(): bool { return $this->isActive; } public function setIsActive(bool $isActive): static { $this->isActive = $isActive; return $this; } /** * @see UserInterface */ public function getUserIdentifier(): string { return (string) $this->email; } /** * @see UserInterface * * @return list */ public function getRoles(): array { $roles = $this->roles; // guarantee every user at least has ROLE_USER $roles[] = 'ROLE_USER'; return array_unique($roles); } /** * @param list $roles */ public function setRoles(array $roles): static { $this->roles = $roles; return $this; } /** * @see PasswordAuthenticatedUserInterface */ public function getPassword(): ?string { return $this->password; } public function setPassword(string $password): static { $this->password = $password; return $this; } /** * @see UserInterface */ public function eraseCredentials(): void { // If you store any temporary, sensitive data on the user, clear it here // $this->plainPassword = null; } public function getCreatedAt(): DateTimeImmutable { return $this->createdAt; } public function getUpdatedAt(): DateTimeImmutable { return $this->updatedAt; } #[ORM\PrePersist] public function setCreatedAtValue(): void { $this->createdAt = new DateTimeImmutable(); $this->updatedAt = new DateTimeImmutable(); } #[ORM\PreUpdate] public function setUpdatedAtValue(): void { $this->updatedAt = new DateTimeImmutable(); } }