<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
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)]
#[ORM\Table(name: '`user`')]
#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
private ?string $email = null;
#[ORM\Column]
private array $roles = [];
/**
* @var string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
#[ORM\Column(length: 150)]
private ?string $firstnameUser = null;
#[ORM\Column(length: 150)]
private ?string $lastnameUser = null;
#[ORM\Column(length: 20)]
private ?string $phoneUser = null;
#[ORM\Column(type: Types::TEXT)]
private ?string $addressUser = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
private ?\DateTimeInterface $birthdateUser = null;
#[ORM\ManyToOne(inversedBy: 'users')]
private ?Sub $sub = null;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Devis::class)]
private Collection $devis;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Contact::class)]
private Collection $contacts;
#[ORM\ManyToMany(targetEntity: Video::class, inversedBy: 'users')]
private Collection $video;
#[ORM\ManyToMany(targetEntity: Program::class, inversedBy: 'users')]
private Collection $program;
#[ORM\Column(type: 'boolean')]
private $isVerified = false;
#[ORM\Column(type: 'boolean')]
private $adminn = false;
public function __construct()
{
$this->devis = new ArrayCollection();
$this->contacts = new ArrayCollection();
$this->video = new ArrayCollection();
$this->program = 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 null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getFirstnameUser(): ?string
{
return $this->firstnameUser;
}
public function setFirstnameUser(string $firstnameUser): self
{
$this->firstnameUser = $firstnameUser;
return $this;
}
public function getLastnameUser(): ?string
{
return $this->lastnameUser;
}
public function setLastnameUser(string $lastnameUser): self
{
$this->lastnameUser = $lastnameUser;
return $this;
}
public function getPhoneUser(): ?string
{
return $this->phoneUser;
}
public function setPhoneUser(string $phoneUser): self
{
$this->phoneUser = $phoneUser;
return $this;
}
public function getAddressUser(): ?string
{
return $this->addressUser;
}
public function setAddressUser(string $addressUser): self
{
$this->addressUser = $addressUser;
return $this;
}
public function getBirthdateUser(): ?\DateTimeInterface
{
return $this->birthdateUser;
}
public function setBirthdateUser(\DateTimeInterface $birthdateUser): self
{
$this->birthdateUser = $birthdateUser;
return $this;
}
public function getSub(): ?Sub
{
return $this->sub;
}
public function setSub(?Sub $sub): self
{
$this->sub = $sub;
return $this;
}
/**
* @return Collection<int, Devis>
*/
public function getDevis(): Collection
{
return $this->devis;
}
public function addDevi(Devis $devi): self
{
if (!$this->devis->contains($devi)) {
$this->devis->add($devi);
$devi->setUser($this);
}
return $this;
}
public function removeDevi(Devis $devi): self
{
if ($this->devis->removeElement($devi)) {
// set the owning side to null (unless already changed)
if ($devi->getUser() === $this) {
$devi->setUser(null);
}
}
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->add($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;
}
/**
* @return Collection<int, Video>
*/
public function getVideo(): Collection
{
return $this->video;
}
public function addVideo(Video $video): self
{
if (!$this->video->contains($video)) {
$this->video->add($video);
}
return $this;
}
public function removeVideo(Video $video): self
{
$this->video->removeElement($video);
return $this;
}
/**
* @return Collection<int, Program>
*/
public function getProgram(): Collection
{
return $this->program;
}
public function addProgram(Program $program): self
{
if (!$this->program->contains($program)) {
$this->program->add($program);
}
return $this;
}
public function removeProgram(Program $program): self
{
$this->program->removeElement($program);
return $this;
}
public function isVerified(): bool
{
return $this->isVerified;
}
public function setIsVerified(bool $isVerified): self
{
$this->isVerified = $isVerified;
return $this;
}
public function isAdminn(): ?bool
{
return $this->adminn;
}
public function setAdminn(bool $adminn): self
{
$this->adminn = $adminn;
return $this;
}
}