"user:list"], read: false ) ] )] class User implements UserInterface, PasswordAuthenticatedUserInterface { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 180)] #[Groups(['user:list'])] private ?string $email = null; /** * @var array The user roles */ #[ORM\Column] #[Groups(['user:list'])] private array $roles = []; /** * @var string|null The hashed password */ #[ORM\Column] private ?string $password = null; /** * @var Collection */ #[ORM\OneToMany(targetEntity: WatchList::class, mappedBy: 'user', orphanRemoval: true)] private Collection $watchLists; public function __construct() { $this->watchLists = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getEmail(): ?string { return $this->email; } public function setEmail(string $email): static { $this->email = $email; return $this; } /** * A visual identifier that represents this user. * * @see UserInterface */ public function getUserIdentifier(): string { return (string)$this->email; } /** * @return list * @see UserInterface * */ public function getRoles(): array { $roles = $this->roles; // guarantee every user at least has ROLE_USER $roles[] = 'ROLE_USER'; return array_unique($roles); } /** * @param array $roles * @return User */ 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; } /** * @return Collection */ public function getWatchLists(): Collection { return $this->watchLists; } public function addWatchList(WatchList $watchList): static { if (!$this->watchLists->contains($watchList)) { $this->watchLists->add($watchList); $watchList->setUser($this); } return $this; } public function removeWatchList(WatchList $watchList): static { if ($this->watchLists->removeElement($watchList)) { // set the owning side to null (unless already changed) if ($watchList->getUser() === $this) { $watchList->setUser(null); } } return $this; } }