<?php
namespace App\Entity;
use App\Repository\UsersRepository;
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: UsersRepository::class)]
#[UniqueEntity(fields: ['username'], message: 'There is already an account with this username')]
class Users implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
private ?string $username = null;
#[ORM\Column]
private array $roles = [];
/**
* @var string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $nom = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $prenom = null;
#[ORM\Column]
private ?bool $enable = false;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $created = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $email = null;
#[ORM\OneToMany(mappedBy: 'userCreated', targetEntity: HonoraireDetFixe::class)]
private Collection $honoraireDetFixes;
#[ORM\OneToMany(mappedBy: 'userCreated', targetEntity: TCnssA00::class)]
private Collection $tCnssA00s;
#[ORM\ManyToOne(targetEntity: self::class)]
private ?self $userUpdated = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $updated = null;
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
private ?PDossier $dossierResponsable = null;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: PNotification::class)]
private Collection $notifications;
public function __construct()
{
$this->honoraireDetFixes = new ArrayCollection();
$this->tCnssA00s = new ArrayCollection();
$this->notifications = new ArrayCollection();
}
// #[ORM\ManyToMany(targetEntity: PDossier::class, mappedBy: 'users')]
// private Collection $dossiers;
// public function __construct()
// {
// $this->operations = new ArrayCollection();
// $this->dossiers = new ArrayCollection();
// }
public function getId(): ?int
{
return $this->id;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->username;
}
/**
* @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;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(?string $nom): self
{
$this->nom = $nom;
return $this;
}
public function getPrenom(): ?string
{
return $this->prenom;
}
public function setPrenom(?string $prenom): self
{
$this->prenom = $prenom;
return $this;
}
public function isEnable(): ?bool
{
return $this->enable;
}
public function setEnable(bool $enable): self
{
$this->enable = $enable;
return $this;
}
public function getCreated(): ?\DateTimeInterface
{
return $this->created;
}
public function setCreated(?\DateTimeInterface $created): self
{
$this->created = $created;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
/**
* @return Collection<int, HonoraireDetFixe>
*/
public function getHonoraireDetFixes(): Collection
{
return $this->honoraireDetFixes;
}
public function addHonoraireDetFix(HonoraireDetFixe $honoraireDetFix): static
{
if (!$this->honoraireDetFixes->contains($honoraireDetFix)) {
$this->honoraireDetFixes->add($honoraireDetFix);
$honoraireDetFix->setUserCreated($this);
}
return $this;
}
public function removeHonoraireDetFix(HonoraireDetFixe $honoraireDetFix): static
{
if ($this->honoraireDetFixes->removeElement($honoraireDetFix)) {
// set the owning side to null (unless already changed)
if ($honoraireDetFix->getUserCreated() === $this) {
$honoraireDetFix->setUserCreated(null);
}
}
return $this;
}
/**
* @return Collection<int, TCnssA00>
*/
public function getTCnssA00s(): Collection
{
return $this->tCnssA00s;
}
public function addTCnssA00(TCnssA00 $tCnssA00): static
{
if (!$this->tCnssA00s->contains($tCnssA00)) {
$this->tCnssA00s->add($tCnssA00);
$tCnssA00->setUserCreated($this);
}
return $this;
}
public function removeTCnssA00(TCnssA00 $tCnssA00): static
{
if ($this->tCnssA00s->removeElement($tCnssA00)) {
// set the owning side to null (unless already changed)
if ($tCnssA00->getUserCreated() === $this) {
$tCnssA00->setUserCreated(null);
}
}
return $this;
}
public function getUserUpdated(): ?self
{
return $this->userUpdated;
}
public function setUserUpdated(?self $userUpdated): static
{
$this->userUpdated = $userUpdated;
return $this;
}
public function getUpdated(): ?\DateTimeInterface
{
return $this->updated;
}
public function setUpdated(?\DateTimeInterface $updated): static
{
$this->updated = $updated;
return $this;
}
public function getDossierResponsable(): ?PDossier
{
return $this->dossierResponsable;
}
public function setDossierResponsable(?PDossier $dossierResponsable): static
{
$this->dossierResponsable = $dossierResponsable;
return $this;
}
/**
* @return Collection<int, PNotification>
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(PNotification $notification): static
{
if (!$this->notifications->contains($notification)) {
$this->notifications->add($notification);
$notification->setUser($this);
}
return $this;
}
public function removeNotification(PNotification $notification): static
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getUser() === $this) {
$notification->setUser(null);
}
}
return $this;
}
}