src/Entity/UserPlatform.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserPlatformRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. /**
  11.  * @ORM\Entity(repositoryClass=UserPlatformRepository::class)
  12.  * @UniqueEntity(
  13.  *     fields={"email"},
  14.  *     message="Cet email est déjà utilisé."
  15.  * )
  16.  */
  17. class UserPlatform implements UserInterface, PasswordAuthenticatedUserInterface
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", length=180, unique=true)
  27.      */
  28.     private $email;
  29.     /**
  30.      * @ORM\Column(type="json")
  31.      */
  32.     private $roles = [];
  33.     /**
  34.      * @var string The hashed password
  35.      * @ORM\Column(type="string")
  36.      */
  37.     private $password;
  38.     /**
  39.      * @ORM\Column(type="string", length=255)
  40.      */
  41.     private $nameuser;
  42.     /**
  43.      * @ORM\Column(type="string", length=255)
  44.      */
  45.     private $adresse;
  46.     /**
  47.      * @ORM\Column(type="string", length=255, nullable=true)
  48.      */
  49.     private $phone;
  50.     /**
  51.      * @ORM\Column(type="string", length=255, nullable=true)
  52.      */
  53.     private $mail;
  54.     /**
  55.      * @ORM\OneToMany(targetEntity=Order::class, mappedBy="customer")
  56.      */
  57.     private $listOrders;
  58.     /**
  59.      * @ORM\OneToMany(targetEntity=Location::class, mappedBy="user")
  60.      */
  61.     private $locations;
  62.     /**
  63.      * @ORM\OneToMany(targetEntity=FreelanceStock::class, mappedBy="freelance")
  64.      */
  65.     private $freelanceStocks;
  66.     /**
  67.      * @ORM\OneToMany(targetEntity=HistoriqueTransactionFreelance::class, mappedBy="freelance")
  68.      */
  69.     private $historiqueTransactions;
  70.     public function __construct()
  71.     {
  72.         $this->listOrders = new ArrayCollection();
  73.         $this->locations = new ArrayCollection();
  74.         $this->freelanceStocks = new ArrayCollection();
  75.         $this->historiqueTransactions = new ArrayCollection();
  76.     }
  77.     public function getId(): ?int
  78.     {
  79.         return $this->id;
  80.     }
  81.     public function getEmail(): ?string
  82.     {
  83.         return $this->email;
  84.     }
  85.     public function setEmail(string $email): self
  86.     {
  87.         $this->email = $email;
  88.         return $this;
  89.     }
  90.     /**
  91.      * A visual identifier that represents this user.
  92.      *
  93.      * @see UserInterface
  94.      */
  95.     public function getUserIdentifier(): string
  96.     {
  97.         return (string) $this->email;
  98.     }
  99.     /**
  100.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  101.      */
  102.     public function getUsername(): string
  103.     {
  104.         return (string) $this->email;
  105.     }
  106.     /**
  107.      * @see UserInterface
  108.      */
  109.     public function getRoles(): array
  110.     {
  111.         $roles = $this->roles;
  112.         // guarantee every user at least has ROLE_USER
  113.         $roles[] = 'ROLE_USER';
  114.         return array_unique($roles);
  115.     }
  116.     public function setRoles(array $roles): self
  117.     {
  118.         $this->roles = $roles;
  119.         return $this;
  120.     }
  121.     /**
  122.      * @see PasswordAuthenticatedUserInterface
  123.      */
  124.     public function getPassword(): string
  125.     {
  126.         return $this->password;
  127.     }
  128.     public function setPassword(string $password): self
  129.     {
  130.         $this->password = $password;
  131.         return $this;
  132.     }
  133.     /**
  134.      * Returning a salt is only needed, if you are not using a modern
  135.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  136.      *
  137.      * @see UserInterface
  138.      */
  139.     public function getSalt(): ?string
  140.     {
  141.         return null;
  142.     }
  143.     /**
  144.      * @see UserInterface
  145.      */
  146.     public function eraseCredentials()
  147.     {
  148.         // If you store any temporary, sensitive data on the user, clear it here
  149.         // $this->plainPassword = null;
  150.     }
  151.     public function getNameuser(): ?string
  152.     {
  153.         return $this->nameuser;
  154.     }
  155.     public function setNameuser(string $nameuser): self
  156.     {
  157.         $this->nameuser = $nameuser;
  158.         return $this;
  159.     }
  160.     public function getAdresse(): ?string
  161.     {
  162.         return $this->adresse;
  163.     }
  164.     public function setAdresse(string $adresse): self
  165.     {
  166.         $this->adresse = $adresse;
  167.         return $this;
  168.     }
  169.     public function getPhone(): ?string
  170.     {
  171.         return $this->phone;
  172.     }
  173.     public function setPhone(?string $phone): self
  174.     {
  175.         $this->phone = $phone;
  176.         return $this;
  177.     }
  178.     public function getMail(): ?string
  179.     {
  180.         return $this->mail;
  181.     }
  182.     public function setMail(?string $mail): self
  183.     {
  184.         $this->mail = $mail;
  185.         return $this;
  186.     }
  187.     /**
  188.      * @return Collection<int, Order>
  189.      */
  190.     public function getListOrders(): Collection
  191.     {
  192.         return $this->listOrders;
  193.     }
  194.     public function addListOrder(Order $listOrder): self
  195.     {
  196.         if (!$this->listOrders->contains($listOrder)) {
  197.             $this->listOrders[] = $listOrder;
  198.             $listOrder->setCustomer($this);
  199.         }
  200.         return $this;
  201.     }
  202.     public function removeListOrder(Order $listOrder): self
  203.     {
  204.         if ($this->listOrders->removeElement($listOrder)) {
  205.             // set the owning side to null (unless already changed)
  206.             if ($listOrder->getCustomer() === $this) {
  207.                 $listOrder->setCustomer(null);
  208.             }
  209.         }
  210.         return $this;
  211.     }
  212.     public function __toString()
  213.     {
  214.         return $this->getNameuser(); // Remplacez getName() par la méthode appropriée pour obtenir une représentation sous forme de chaîne.
  215.     }
  216.     /**
  217.      * @return Collection<int, Location>
  218.      */
  219.     public function getLocations(): Collection
  220.     {
  221.         return $this->locations;
  222.     }
  223.     public function addLocation(Location $location): self
  224.     {
  225.         if (!$this->locations->contains($location)) {
  226.             $this->locations[] = $location;
  227.             $location->setUser($this);
  228.         }
  229.         return $this;
  230.     }
  231.     public function removeLocation(Location $location): self
  232.     {
  233.         if ($this->locations->removeElement($location)) {
  234.             // set the owning side to null (unless already changed)
  235.             if ($location->getUser() === $this) {
  236.                 $location->setUser(null);
  237.             }
  238.         }
  239.         return $this;
  240.     }
  241.     /**
  242.      * @return Collection<int, FreelanceStock>
  243.      */
  244.     public function getFreelanceStocks(): Collection
  245.     {
  246.         return $this->freelanceStocks;
  247.     }
  248.     public function addFreelanceStock(FreelanceStock $freelanceStock): self
  249.     {
  250.         if (!$this->freelanceStocks->contains($freelanceStock)) {
  251.             $this->freelanceStocks[] = $freelanceStock;
  252.             $freelanceStock->setFreelance($this);
  253.         }
  254.         return $this;
  255.     }
  256.     public function removeFreelanceStock(FreelanceStock $freelanceStock): self
  257.     {
  258.         if ($this->freelanceStocks->removeElement($freelanceStock)) {
  259.             if ($freelanceStock->getFreelance() === $this) {
  260.                 $freelanceStock->setFreelance(null);
  261.             }
  262.         }
  263.         return $this;
  264.     }
  265.     /**
  266.      * @return Collection<int, HistoriqueTransactionFreelance>
  267.      */
  268.     public function getHistoriqueTransactions(): Collection
  269.     {
  270.         return $this->historiqueTransactions;
  271.     }
  272.     public function addHistoriqueTransaction(HistoriqueTransactionFreelance $historiqueTransaction): self
  273.     {
  274.         if (!$this->historiqueTransactions->contains($historiqueTransaction)) {
  275.             $this->historiqueTransactions[] = $historiqueTransaction;
  276.             $historiqueTransaction->setFreelance($this);
  277.         }
  278.         return $this;
  279.     }
  280.     public function removeHistoriqueTransaction(HistoriqueTransactionFreelance $historiqueTransaction): self
  281.     {
  282.         if ($this->historiqueTransactions->removeElement($historiqueTransaction)) {
  283.             if ($historiqueTransaction->getFreelance() === $this) {
  284.                 $historiqueTransaction->setFreelance(null);
  285.             }
  286.         }
  287.         return $this;
  288.     }
  289. }