The user roles */ #[ORM\Column(type: Types::JSON)] public array $roles = []; /** @var string The hashed password */ #[ORM\Column] public string $password; /** @var Collection */ #[ORM\ManyToMany(targetEntity: Season::class, mappedBy: 'owners')] public private(set) Collection $seasons; #[ORM\Column] public bool $isVerified = false; public bool $isAdmin { get => \in_array('ROLE_ADMIN', $this->getRoles(), true); } public function __construct() { $this->seasons = new ArrayCollection(); } /** * A visual identifier that represents this user. * * @see UserInterface * * @return non-empty-string */ public function getUserIdentifier(): string { /** @var non-empty-string $identifier */ $identifier = $this->email; return $identifier; } /** * @see UserInterface * * @return non-empty-array, string> */ public function getRoles(): array { $roles = $this->roles; // guarantee every user at least has ROLE_USER $roles[] = 'ROLE_USER'; return array_unique($roles); } /** @see PasswordAuthenticatedUserInterface */ public function getPassword(): ?string { return $this->password; } /** @see UserInterface */ public function eraseCredentials(): void { // If you store any temporary, sensitive data on the user, clear it here // $this->plainPassword = null; } public function addSeason(Season $season): static { if (!$this->seasons->contains($season)) { $this->seasons->add($season); $season->addOwner($this); } return $this; } public function removeSeason(Season $season): static { if ($this->seasons->removeElement($season)) { $season->removeOwner($this); } return $this; } }