<?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\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: UserRepository::class)]
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: 200, unique: true)]
private ?string $username = null;
#[ORM\Column]
private ?int $etat = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $createdAt = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $updatedAt = null;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Eleveur::class)]
private Collection $eleveurs;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Inseminateur::class)]
private Collection $inseminateurs;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: AgentOep::class)]
private Collection $agentOeps;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Agent::class)]
private Collection $agents;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Consultation::class)]
private Collection $consultations;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Partenaire::class)]
private Collection $partenaires;
public function __construct()
{
$this->eleveurs = new ArrayCollection();
$this->inseminateurs = new ArrayCollection();
$this->agentOeps = new ArrayCollection();
$this->agents = new ArrayCollection();
$this->consultations = new ArrayCollection();
$this->partenaires = 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;
}
/**
* @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 getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
public function getEtat(): ?int
{
return $this->etat;
}
public function setEtat(int $etat): self
{
$this->etat = $etat;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return Collection<int, Eleveur>
*/
public function getEleveurs(): Collection
{
return $this->eleveurs;
}
public function addEleveur(Eleveur $eleveur): self
{
if (!$this->eleveurs->contains($eleveur)) {
$this->eleveurs[] = $eleveur;
$eleveur->setUser($this);
}
return $this;
}
public function removeEleveur(Eleveur $eleveur): self
{
if ($this->eleveurs->removeElement($eleveur)) {
// set the owning side to null (unless already changed)
if ($eleveur->getUser() === $this) {
$eleveur->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Inseminateur>
*/
public function getInseminateurs(): Collection
{
return $this->inseminateurs;
}
public function addInseminateur(Inseminateur $inseminateur): self
{
if (!$this->inseminateurs->contains($inseminateur)) {
$this->inseminateurs[] = $inseminateur;
$inseminateur->setUser($this);
}
return $this;
}
public function removeInseminateur(Inseminateur $inseminateur): self
{
if ($this->inseminateurs->removeElement($inseminateur)) {
// set the owning side to null (unless already changed)
if ($inseminateur->getUser() === $this) {
$inseminateur->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, AgentOep>
*/
public function getAgentOeps(): Collection
{
return $this->agentOeps;
}
public function addAgentOep(AgentOep $agentOep): self
{
if (!$this->agentOeps->contains($agentOep)) {
$this->agentOeps[] = $agentOep;
$agentOep->setUser($this);
}
return $this;
}
public function removeAgentOep(AgentOep $agentOep): self
{
if ($this->agentOeps->removeElement($agentOep)) {
// set the owning side to null (unless already changed)
if ($agentOep->getUser() === $this) {
$agentOep->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Agent>
*/
public function getAgents(): Collection
{
return $this->agents;
}
public function addAgent(Agent $agent): self
{
if (!$this->agents->contains($agent)) {
$this->agents[] = $agent;
$agent->setUser($this);
}
return $this;
}
public function removeAgent(Agent $agent): self
{
if ($this->agents->removeElement($agent)) {
// set the owning side to null (unless already changed)
if ($agent->getUser() === $this) {
$agent->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Consultation>
*/
public function getConsultations(): Collection
{
return $this->consultations;
}
public function addConsultation(Consultation $consultation): self
{
if (!$this->consultations->contains($consultation)) {
$this->consultations[] = $consultation;
$consultation->setUser($this);
}
return $this;
}
public function removeConsultation(Consultation $consultation): self
{
if ($this->consultations->removeElement($consultation)) {
// set the owning side to null (unless already changed)
if ($consultation->getUser() === $this) {
$consultation->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Partenaire>
*/
public function getPartenaires(): Collection
{
return $this->partenaires;
}
public function addPartenaire(Partenaire $partenaire): self
{
if (!$this->partenaires->contains($partenaire)) {
$this->partenaires[] = $partenaire;
$partenaire->setUser($this);
}
return $this;
}
public function removePartenaire(Partenaire $partenaire): self
{
if ($this->partenaires->removeElement($partenaire)) {
// set the owning side to null (unless already changed)
if ($partenaire->getUser() === $this) {
$partenaire->setUser(null);
}
}
return $this;
}
}