<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @UniqueEntity(fields={"email"}, message="Cette adresse email est déjà utilisée.")
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\Column(type="boolean")
*/
private $isVerified = false;
/**
* @ORM\Column(type="string", length=255)
*/
private $salt;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $firstName;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $lastName;
/**
* @ORM\Column(type="boolean")
*/
private $isActive;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime")
*/
private $modifiedAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $recentlyLoggedAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $disabledAt;
/**
* @ORM\OneToMany(targetEntity=FlashUserWorkshop::class, mappedBy="user")
*/
private $flashUserWorkshops;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $jobTitle;
/**
* @ORM\ManyToMany(targetEntity=Job::class, inversedBy="users")
*/
private $job;
/**
* @ORM\ManyToMany(targetEntity=Subject::class, inversedBy="users")
*/
private $subject;
/**
* @ORM\ManyToOne(targetEntity=Location::class, inversedBy="users")
* @ORM\JoinColumn(nullable=true)
*/
private $location;
/**
* @ORM\ManyToOne(targetEntity=SubLocation::class, inversedBy="users")
* @ORM\JoinColumn(nullable=true)
*/
private $subLocation;
/**
* @ORM\ManyToOne(targetEntity=Client::class, inversedBy="users")
* @ORM\JoinColumn(nullable=false)
*/
private $client;
/**
* @ORM\OneToMany(targetEntity=UserProduct::class, mappedBy="user")
*/
private $userProducts;
/**
* @ORM\OneToMany(targetEntity=DefiAnswerUser::class, mappedBy="user")
*/
private $defiAnswerUsers;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $icon;
/**
* @ORM\OneToMany(targetEntity=Contact::class, mappedBy="user")
*/
private $contacts;
/**
* @ORM\ManyToOne(targetEntity=Avatar::class, inversedBy="users")
*/
private $avatar;
/**
* @ORM\Column(type="string", length=30, nullable=true)
*/
private $age;
/**
* @ORM\OneToMany(targetEntity=DiagAnswerUser::class, mappedBy="user")
*/
private $diagAnswerUsers;
public function __construct()
{
$this->flashUserWorkshops = new ArrayCollection();
$this->job = new ArrayCollection();
$this->subject = new ArrayCollection();
$this->userProducts = new ArrayCollection();
$this->defiAnswerUsers = new ArrayCollection();
$this->contacts = new ArrayCollection();
$this->diagAnswerUsers = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return $this->salt;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function isVerified(): bool
{
return $this->isVerified;
}
public function setIsVerified(bool $isVerified): self
{
$this->isVerified = $isVerified;
return $this;
}
public function setSalt(string $salt): self
{
$this->salt = $salt;
return $this;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function isIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getModifiedAt(): ?\DateTimeInterface
{
return $this->modifiedAt;
}
public function setModifiedAt(\DateTimeInterface $modifiedAt): self
{
$this->modifiedAt = $modifiedAt;
return $this;
}
public function getRecentlyLoggedAt(): ?\DateTimeInterface
{
return $this->recentlyLoggedAt;
}
public function setRecentlyLoggedAt(?\DateTimeInterface $recentlyLoggedAt): self
{
$this->recentlyLoggedAt = $recentlyLoggedAt;
return $this;
}
public function getDisabledAt(): ?\DateTimeInterface
{
return $this->disabledAt;
}
public function setDisabledAt(?\DateTimeInterface $disabledAt): self
{
$this->disabledAt = $disabledAt;
return $this;
}
/**
* @return Collection<int, FlashUserWorkshop>
*/
public function getFlashUserWorkshops(): Collection
{
return $this->flashUserWorkshops;
}
public function addFlashUserWorkshop(FlashUserWorkshop $flashUserWorkshop): self
{
if (!$this->flashUserWorkshops->contains($flashUserWorkshop)) {
$this->flashUserWorkshops[] = $flashUserWorkshop;
$flashUserWorkshop->setUser($this);
}
return $this;
}
public function removeFlashUserWorkshop(FlashUserWorkshop $flashUserWorkshop): self
{
if ($this->flashUserWorkshops->removeElement($flashUserWorkshop)) {
// set the owning side to null (unless already changed)
if ($flashUserWorkshop->getUser() === $this) {
$flashUserWorkshop->setUser(null);
}
}
return $this;
}
public function getJobTitle(): ?string
{
return $this->jobTitle;
}
public function setJobTitle(string $jobTitle = null): self
{
$this->jobTitle = $jobTitle;
return $this;
}
/**
* @return Collection<int, Job>
*/
public function getJob(): Collection
{
return $this->job;
}
public function addJob(Job $job): self
{
if (!$this->job->contains($job)) {
$this->job[] = $job;
}
return $this;
}
public function removeJob(Job $job): self
{
$this->job->removeElement($job);
return $this;
}
/**
* @return Collection<int, Subject>
*/
public function getSubject(): Collection
{
return $this->subject;
}
public function addSubject(Subject $subject): self
{
if (!$this->subject->contains($subject)) {
$this->subject[] = $subject;
}
return $this;
}
public function removeSubject(Subject $subject): self
{
$this->subject->removeElement($subject);
return $this;
}
public function getLocation(): ?Location
{
return $this->location;
}
public function setLocation(?Location $location): self
{
$this->location = $location;
return $this;
}
public function getSubLocation(): ?SubLocation
{
return $this->subLocation;
}
public function setSubLocation(?SubLocation $subLocation): self
{
$this->subLocation = $subLocation;
return $this;
}
public function getClient(): ?Client
{
return $this->client;
}
public function setClient(?Client $client): self
{
$this->client = $client;
return $this;
}
/**
* @return Collection<int, UserProduct>
*/
public function getUserProducts(): Collection
{
return $this->userProducts;
}
public function addUserProduct(UserProduct $userProduct): self
{
if (!$this->userProducts->contains($userProduct)) {
$this->userProducts[] = $userProduct;
$userProduct->setUser($this);
}
return $this;
}
public function removeUserProduct(UserProduct $userProduct): self
{
if ($this->userProducts->removeElement($userProduct)) {
// set the owning side to null (unless already changed)
if ($userProduct->getUser() === $this) {
$userProduct->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, DefiAnswerUser>
*/
public function getDefiAnswerUsers(): Collection
{
return $this->defiAnswerUsers;
}
public function addDefiAnswerUser(DefiAnswerUser $defiAnswerUser): self
{
if (!$this->defiAnswerUsers->contains($defiAnswerUser)) {
$this->defiAnswerUsers[] = $defiAnswerUser;
$defiAnswerUser->setUser($this);
}
return $this;
}
public function removeDefiAnswerUser(DefiAnswerUser $defiAnswerUser): self
{
if ($this->defiAnswerUsers->removeElement($defiAnswerUser)) {
// set the owning side to null (unless already changed)
if ($defiAnswerUser->getUser() === $this) {
$defiAnswerUser->setUser(null);
}
}
return $this;
}
public function getIcon(): ?string
{
return $this->icon;
}
public function setIcon(?string $icon): self
{
$this->icon = $icon;
return $this;
}
/**
* @return Collection<int, Contact>
*/
public function getContacts(): Collection
{
return $this->contacts;
}
public function addContact(Contact $contact): self
{
if (!$this->contacts->contains($contact)) {
$this->contacts[] = $contact;
$contact->setUser($this);
}
return $this;
}
public function removeContact(Contact $contact): self
{
if ($this->contacts->removeElement($contact)) {
// set the owning side to null (unless already changed)
if ($contact->getUser() === $this) {
$contact->setUser(null);
}
}
return $this;
}
public function getAvatar(): ?Avatar
{
return $this->avatar;
}
public function setAvatar(?Avatar $avatar): self
{
$this->avatar = $avatar;
return $this;
}
public function getAge(): ?string
{
return $this->age;
}
public function setAge(?string $age): self
{
$this->age = $age;
return $this;
}
/**
* @return Collection<int, DiagAnswerUser>
*/
public function getDiagAnswerUsers(): Collection
{
return $this->diagAnswerUsers;
}
public function addDiagAnswerUser(DiagAnswerUser $diagAnswerUser): self
{
if (!$this->diagAnswerUsers->contains($diagAnswerUser)) {
$this->diagAnswerUsers[] = $diagAnswerUser;
$diagAnswerUser->setUser($this);
}
return $this;
}
public function removeDiagAnswerUser(DiagAnswerUser $diagAnswerUser): self
{
if ($this->diagAnswerUsers->removeElement($diagAnswerUser)) {
// set the owning side to null (unless already changed)
if ($diagAnswerUser->getUser() === $this) {
$diagAnswerUser->setUser(null);
}
}
return $this;
}
}