<?php
namespace App\Entity;
use App\Repository\UserPlatformRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=UserPlatformRepository::class)
*/
class UserPlatform 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="string", nullable=true)
*/
private ?string $resetToken = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTimeInterface $tokenExpiration = null;
/**
* @ORM\Column(type="string", length=255)
*/
private $nameuser;
/**
* @ORM\Column(type="string", length=255)
*/
private $adresse;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $adresseLivraison;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $mail;
/**
* @ORM\OneToMany(targetEntity=Order::class, mappedBy="customer")
*/
private $listOrders;
public function __construct()
{
$this->listOrders = 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 getNameuser(): ?string
{
return $this->nameuser;
}
public function setNameuser(string $nameuser): self
{
$this->nameuser = $nameuser;
return $this;
}
public function getAdresse(): ?string
{
return $this->adresse;
}
public function setAdresse(string $adresse): self
{
$this->adresse = $adresse;
return $this;
}
public function getAdresseLivraison(): ?string
{
return $this->adresseLivraison;
}
public function setAdresseLivraison(string $adresseLivraison): self
{
$this->adresseLivraison = $adresseLivraison;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getMail(): ?string
{
return $this->mail;
}
public function setMail(?string $mail): self
{
$this->mail = $mail;
return $this;
}
/**
* @return Collection<int, Order>
*/
public function getListOrders(): Collection
{
return $this->listOrders;
}
public function addListOrder(Order $listOrder): self
{
if (!$this->listOrders->contains($listOrder)) {
$this->listOrders[] = $listOrder;
$listOrder->setCustomer($this);
}
return $this;
}
public function removeListOrder(Order $listOrder): self
{
if ($this->listOrders->removeElement($listOrder)) {
// set the owning side to null (unless already changed)
if ($listOrder->getCustomer() === $this) {
$listOrder->setCustomer(null);
}
}
return $this;
}
public function __toString()
{
return $this->getNameuser(); // Remplacez getName() par la méthode appropriée pour obtenir une représentation sous forme de chaîne.
}
/**
* Get the value of resetToken
*/
public function getResetToken(): ?string
{
return $this->resetToken;
}
/**
* Set the value of resetToken
*/
public function setResetToken(?string $resetToken): self
{
$this->resetToken = $resetToken;
return $this;
}
/**
* Get the value of tokenExpiration
*/
public function getTokenExpiration(): ?\DateTimeInterface
{
return $this->tokenExpiration;
}
/**
* Set the value of tokenExpiration
*/
public function setTokenExpiration(?\DateTimeInterface $tokenExpiration): self
{
$this->tokenExpiration = $tokenExpiration;
return $this;
}
}