<?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;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass=UserPlatformRepository::class)
* @UniqueEntity(
* fields={"email"},
* message="Cet email est déjà utilisé."
* )
*/
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", length=255)
*/
private $nameuser;
/**
* @ORM\Column(type="string", length=255)
*/
private $adresse;
/**
* @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;
/**
* @ORM\OneToMany(targetEntity=Location::class, mappedBy="user")
*/
private $locations;
/**
* @ORM\OneToMany(targetEntity=FreelanceStock::class, mappedBy="freelance")
*/
private $freelanceStocks;
/**
* @ORM\OneToMany(targetEntity=HistoriqueTransactionFreelance::class, mappedBy="freelance")
*/
private $historiqueTransactions;
public function __construct()
{
$this->listOrders = new ArrayCollection();
$this->locations = new ArrayCollection();
$this->freelanceStocks = new ArrayCollection();
$this->historiqueTransactions = 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 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.
}
/**
* @return Collection<int, Location>
*/
public function getLocations(): Collection
{
return $this->locations;
}
public function addLocation(Location $location): self
{
if (!$this->locations->contains($location)) {
$this->locations[] = $location;
$location->setUser($this);
}
return $this;
}
public function removeLocation(Location $location): self
{
if ($this->locations->removeElement($location)) {
// set the owning side to null (unless already changed)
if ($location->getUser() === $this) {
$location->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, FreelanceStock>
*/
public function getFreelanceStocks(): Collection
{
return $this->freelanceStocks;
}
public function addFreelanceStock(FreelanceStock $freelanceStock): self
{
if (!$this->freelanceStocks->contains($freelanceStock)) {
$this->freelanceStocks[] = $freelanceStock;
$freelanceStock->setFreelance($this);
}
return $this;
}
public function removeFreelanceStock(FreelanceStock $freelanceStock): self
{
if ($this->freelanceStocks->removeElement($freelanceStock)) {
if ($freelanceStock->getFreelance() === $this) {
$freelanceStock->setFreelance(null);
}
}
return $this;
}
/**
* @return Collection<int, HistoriqueTransactionFreelance>
*/
public function getHistoriqueTransactions(): Collection
{
return $this->historiqueTransactions;
}
public function addHistoriqueTransaction(HistoriqueTransactionFreelance $historiqueTransaction): self
{
if (!$this->historiqueTransactions->contains($historiqueTransaction)) {
$this->historiqueTransactions[] = $historiqueTransaction;
$historiqueTransaction->setFreelance($this);
}
return $this;
}
public function removeHistoriqueTransaction(HistoriqueTransactionFreelance $historiqueTransaction): self
{
if ($this->historiqueTransactions->removeElement($historiqueTransaction)) {
if ($historiqueTransaction->getFreelance() === $this) {
$historiqueTransaction->setFreelance(null);
}
}
return $this;
}
}