src/Entity/User.php line 14

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. #[ORM\Entity(repositoryClassUserRepository::class)]
  10. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  11. class User implements UserInterfacePasswordAuthenticatedUserInterface
  12. {
  13.     public static function generatePassword($length 8)
  14.     {
  15.         $chars 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*()-_=+';
  16.         $password '';
  17.         for ($i 0$i $length$i++) {
  18.             $password .= $chars[rand(0strlen($chars) - 1)];
  19.         }
  20.         return $password;
  21.     }
  22.     #[ORM\Id]
  23.     #[ORM\GeneratedValue]
  24.     #[ORM\Column]
  25.     private ?int $id null;
  26.     #[ORM\Column(length180uniquetrue)]
  27.     private ?string $email null;
  28.     #[ORM\Column]
  29.     private array $roles = [];
  30.     #[ORM\OneToMany(mappedBy'user'targetEntityCart::class, cascade: ['remove'], orphanRemovaltrue)]
  31.     private ?Collection $cart;
  32.     #[ORM\OneToMany(mappedBy'user'targetEntitySpecialCustomer::class, cascade: ['remove'], orphanRemovaltrue)]
  33.     private ?Collection $specialCustomerPourcent;
  34.     #[ORM\Column(name'specialCustomer'type'boolean'nullabletrue)]
  35.     private ?bool $specialCustomer;
  36.     #[ORM\OneToMany(mappedBy'user'targetEntityCustomerControl::class, cascade: ['remove'], orphanRemovaltrue)]
  37.     private ?Collection $customer;
  38.     #[ORM\OneToMany(mappedBy'customer'targetEntityCustomerControl::class, cascade: ['remove'], orphanRemovaltrue)]
  39.     private ?Collection $customerControl;
  40.     #[ORM\OneToMany(mappedBy'user'targetEntityBillings::class, cascade: ['remove'], orphanRemovaltrue)]
  41.     private ?Collection $billings;
  42.     #[ORM\OneToMany(mappedBy'user'targetEntityInvoices::class, cascade: ['remove'], orphanRemovaltrue)]
  43.     private ?Collection $invoice;
  44.     #[ORM\OneToMany(mappedBy'user'targetEntityCartFinished::class, cascade: ['remove'], orphanRemovaltrue)]
  45.     private ?Collection $cartFinished;
  46.     #[ORM\OneToMany(mappedBy'user'targetEntityAdditionalCompanyInformation::class, cascade: ['remove'], orphanRemovaltrue)]
  47.     private ?Collection $AdditionalCompanyInformation;
  48.     #[ORM\OneToMany(mappedBy'user'targetEntityJoker::class, cascade: ['remove'], orphanRemovaltrue)]
  49.     private ?Collection $joker;
  50.     #[ORM\OneToMany(mappedBy'user'targetEntityDeliveryAddress::class, cascade: ['remove'], orphanRemovaltrue)]
  51.     private ?Collection $deliveryAddress;
  52.     #[ORM\OneToMany(mappedBy'client'targetEntityTva::class, cascade: ['remove'], orphanRemovaltrue)]
  53.     private ?Collection $tva;
  54.     #[ORM\Column(name'generatePasswordRecovery'type'string'nullabletrue)]
  55.     private ?string $generatePasswordRecovery;
  56.     #[ORM\Column(name'resetToken'type'string'length100nullabletrue)]
  57.     private ?string $resetToken null;
  58.     #[ORM\Column(name'resetTokenExpiresAt'type'datetime'nullabletrue)]
  59.     private ?\DateTimeInterface $resetTokenExpiresAt null;
  60.     //    #[ORM\Column(name: 'typeOfProfessional', type: 'string', nullable: true)]
  61.     //    private ?string $typeOfProfessional;
  62.     #[ORM\Column(name'additionalPercentage'type'float'nullabletrue)]
  63.     private ?float $additionalPercentage 0.0;
  64.     #[ORM\Column(name'name'type'string'nullabletrue)]
  65.     private ?string $name;
  66.     #[ORM\Column(name'firstName'type'string'nullabletrue)]
  67.     private ?string $firstName;
  68.     #[ORM\Column(name'address'type'string'nullabletrue)]
  69.     private ?string $address;
  70.     #[ORM\Column(name'postal'type'string'nullabletrue)]
  71.     private ?string $postal;
  72.     #[ORM\Column(name'locality'type'string'nullabletrue)]
  73.     private ?string $locality;
  74.     #[ORM\Column(name'country'type'string'nullabletrue)]
  75.     private ?string $country;
  76.     #[ORM\Column(name'phoneNumber'type'string'nullabletrue)]
  77.     private ?string $phoneNumber;
  78.     #[ORM\Column(name'directPhone'type'string'nullabletrue)]
  79.     private ?string $directPhone;
  80.     #[ORM\Column(name'otherMail'type'string'nullabletrue)]
  81.     private ?string $otherMail;
  82.     #[ORM\Column(name'companyName'type'string'nullabletrue)]
  83.     private ?string $companyName;
  84.     #[ORM\Column(name'active'type'boolean'nullabletrue)]
  85.     private ?bool $active;
  86.     #[ORM\Column(name'gender'type'string'nullabletrue)]
  87.     private ?string $gender;
  88.     #[ORM\Column(name'userSupplementsPurchaseDecisionMaker'type'boolean'nullabletrue)]
  89.     private ?bool $userSupplementsPurchaseDecisionMaker;
  90.     /**
  91.      * @return string|null
  92.      */
  93.     public function getGeneratePasswordRecovery(): ?string
  94.     {
  95.         return $this->generatePasswordRecovery;
  96.     }
  97.     /**
  98.      * @param string|null $generatePasswordRecovery
  99.      */
  100.     public function setGeneratePasswordRecovery(?string $generatePasswordRecovery): void
  101.     {
  102.         $this->generatePasswordRecovery $generatePasswordRecovery;
  103.     }
  104.     /**
  105.      * @return Collection|null
  106.      */
  107.     public function getSpecialCustomerPourcent(): ?Collection
  108.     {
  109.         return $this->specialCustomerPourcent;
  110.     }
  111.     /**
  112.      * @param Collection|null $specialCustomerPourcent
  113.      */
  114.     public function setSpecialCustomerPourcent(?Collection $specialCustomerPourcent): void
  115.     {
  116.         $this->specialCustomerPourcent $specialCustomerPourcent;
  117.     }
  118.     /**
  119.      * @return bool|null
  120.      */
  121.     public function getSpecialCustomer(): ?bool
  122.     {
  123.         return $this->specialCustomer;
  124.     }
  125.     /**
  126.      * @param bool|null $specialCustomer
  127.      */
  128.     public function setSpecialCustomer(?bool $specialCustomer): void
  129.     {
  130.         $this->specialCustomer $specialCustomer;
  131.     }
  132.     /**
  133.      * @return Collection|null
  134.      */
  135.     public function getInvoice(): ?Collection
  136.     {
  137.         return $this->invoice;
  138.     }
  139.     /**
  140.      * @param Collection|null $invoice
  141.      */
  142.     public function setInvoice(?Collection $invoice): void
  143.     {
  144.         $this->invoice $invoice;
  145.     }
  146.     /**
  147.      * @return Collection|null
  148.      */
  149.     public function getCustomer(): ?Collection
  150.     {
  151.         return $this->customer;
  152.     }
  153.     /**
  154.      * @param Collection|null $customer
  155.      */
  156.     public function setCustomer(?Collection $customer): void
  157.     {
  158.         $this->customer $customer;
  159.     }
  160.     /**
  161.      * @return Collection|null
  162.      */
  163.     public function getCustomerControl(): ?Collection
  164.     {
  165.         return $this->customerControl;
  166.     }
  167.     /**
  168.      * @param Collection|null $customerControl
  169.      */
  170.     public function setCustomerControl(?Collection $customerControl): void
  171.     {
  172.         $this->customerControl $customerControl;
  173.     }
  174.     /**
  175.      * @return bool|null
  176.      */
  177.     public function getUserSupplementsPurchaseDecisionMaker(): ?bool
  178.     {
  179.         return $this->userSupplementsPurchaseDecisionMaker;
  180.     }
  181.     /**
  182.      * @param bool|null $userSupplementsPurchaseDecisionMaker
  183.      */
  184.     public function setUserSupplementsPurchaseDecisionMaker(?bool $userSupplementsPurchaseDecisionMaker): void
  185.     {
  186.         $this->userSupplementsPurchaseDecisionMaker $userSupplementsPurchaseDecisionMaker;
  187.     }
  188.     /**
  189.      * @return string|null
  190.      */
  191.     public function getGender(): ?string
  192.     {
  193.         return $this->gender;
  194.     }
  195.     /**
  196.      * @param string|null $gender
  197.      */
  198.     public function setGender(?string $gender): void
  199.     {
  200.         $this->gender $gender;
  201.     }
  202.     /**
  203.      * @return Collection|null
  204.      */
  205.     public function getBillings(): ?Collection
  206.     {
  207.         return $this->billings;
  208.     }
  209.     /**
  210.      * @param Collection|null $billings
  211.      */
  212.     public function setBillings(?Collection $billings): void
  213.     {
  214.         $this->billings $billings;
  215.     }
  216.     /**
  217.      * @return string|null
  218.      */
  219.     public function getDirectPhone(): ?string
  220.     {
  221.         return $this->directPhone;
  222.     }
  223.     /**
  224.      * @param string|null $directPhone
  225.      */
  226.     public function setDirectPhone(?string $directPhone): void
  227.     {
  228.         $this->directPhone $directPhone;
  229.     }
  230.     /**
  231.      * @return string|null
  232.      */
  233.     public function getLocality(): ?string
  234.     {
  235.         return $this->locality;
  236.     }
  237.     /**
  238.      * @param string|null $locality
  239.      */
  240.     public function setLocality(?string $locality): void
  241.     {
  242.         $this->locality $locality;
  243.     }
  244.     /**
  245.      * @return Collection|null
  246.      */
  247.     public function getCartFinished(): ?Collection
  248.     {
  249.         return $this->cartFinished;
  250.     }
  251.     /**
  252.      * @param Collection|null $cartFinished
  253.      */
  254.     public function setCartFinished(?Collection $cartFinished): void
  255.     {
  256.         $this->cartFinished $cartFinished;
  257.     }
  258.     /**
  259.      * @return float|null
  260.      */
  261.     public function getAdditionalPercentage(): ?float
  262.     {
  263.         return $this->additionalPercentage;
  264.     }
  265.     /**
  266.      * @param float|null $additionalPercentage
  267.      */
  268.     public function setAdditionalPercentage(?float $additionalPercentage): void
  269.     {
  270.         $this->additionalPercentage $additionalPercentage;
  271.     }
  272.     /**
  273.      * @return Collection|null
  274.      */
  275.     public function getAdditionalCompanyInformation(): ?Collection
  276.     {
  277.         return $this->AdditionalCompanyInformation;
  278.     }
  279.     /**
  280.      * @param Collection|null $AdditionalCompanyInformation
  281.      */
  282.     public function setAdditionalCompanyInformation(?Collection $AdditionalCompanyInformation): void
  283.     {
  284.         $this->AdditionalCompanyInformation $AdditionalCompanyInformation;
  285.     }
  286.     /**
  287.      * @return Collection|null
  288.      */
  289.     public function getJoker(): ?Collection
  290.     {
  291.         return $this->joker;
  292.     }
  293.     /**
  294.      * @param Collection|null $joker
  295.      */
  296.     public function setJoker(?Collection $joker): void
  297.     {
  298.         $this->joker $joker;
  299.     }
  300.     /**
  301.      * @return bool|null
  302.      */
  303.     public function getActive(): ?bool
  304.     {
  305.         return $this->active;
  306.     }
  307.     /**
  308.      * @param bool|null $active
  309.      */
  310.     public function setActive(?bool $active false): void
  311.     {
  312.         $this->active $active;
  313.     }
  314.     /**
  315.      * @return Collection|null
  316.      */
  317.     public function getDeliveryAddress(): ?Collection
  318.     {
  319.         return $this->deliveryAddress;
  320.     }
  321.     /**
  322.      * @param Collection|null $deliveryAddress
  323.      */
  324.     public function setDeliveryAddress(?Collection $deliveryAddress): void
  325.     {
  326.         $this->deliveryAddress $deliveryAddress;
  327.     }
  328.     /**
  329.      * @return Collection|null
  330.      */
  331.     public function getTva(): ?Collection
  332.     {
  333.         return $this->tva;
  334.     }
  335.     /**
  336.      * @param Collection|null $tva
  337.      */
  338.     public function setTva(?Collection $tva): void
  339.     {
  340.         $this->tva $tva;
  341.     }
  342.     /**
  343.      * @return string|null
  344.      */
  345.     public function getName(): ?string
  346.     {
  347.         return $this->name;
  348.     }
  349.     /**
  350.      * @param string|null $name
  351.      */
  352.     public function setName(?string $name): void
  353.     {
  354.         $this->name $name;
  355.     }
  356.     /**
  357.      * @return string|null
  358.      */
  359.     public function getFirstName(): ?string
  360.     {
  361.         return $this->firstName;
  362.     }
  363.     /**
  364.      * @param string|null $firstName
  365.      */
  366.     public function setFirstName(?string $firstName): void
  367.     {
  368.         $this->firstName $firstName;
  369.     }
  370.     /**
  371.      * @return string|null
  372.      */
  373.     public function getAddress(): ?string
  374.     {
  375.         return $this->address;
  376.     }
  377.     /**
  378.      * @param string|null $address
  379.      */
  380.     public function setAddress(?string $address): void
  381.     {
  382.         $this->address $address;
  383.     }
  384.     /**
  385.      * @return string|null
  386.      */
  387.     public function getCountry(): ?string
  388.     {
  389.         return $this->country;
  390.     }
  391.     /**
  392.      * @param string|null $country
  393.      */
  394.     public function setCountry(?string $country): void
  395.     {
  396.         $this->country $country;
  397.     }
  398.     /**
  399.      * @return string|null
  400.      */
  401.     public function getPostal(): ?string
  402.     {
  403.         return $this->postal;
  404.     }
  405.     /**
  406.      * @param string|null $postal
  407.      */
  408.     public function setPostal(?string $postal): void
  409.     {
  410.         $this->postal $postal;
  411.     }
  412.     /**
  413.      * @return string|null
  414.      */
  415.     public function getPhoneNumber(): ?string
  416.     {
  417.         return $this->phoneNumber;
  418.     }
  419.     /**
  420.      * @param string|null $phoneNumber
  421.      */
  422.     public function setPhoneNumber(?string $phoneNumber): void
  423.     {
  424.         $this->phoneNumber $phoneNumber;
  425.     }
  426.     /**
  427.      * @return string|null
  428.      */
  429.     public function getOtherMail(): ?string
  430.     {
  431.         return $this->otherMail;
  432.     }
  433.     /**
  434.      * @param string|null $otherMail
  435.      */
  436.     public function setOtherMail(?string $otherMail): void
  437.     {
  438.         $this->otherMail $otherMail;
  439.     }
  440.     /**
  441.      * @return string|null
  442.      */
  443.     public function getCompanyName(): ?string
  444.     {
  445.         return $this->companyName;
  446.     }
  447.     /**
  448.      * @param string|null $companyName
  449.      */
  450.     public function setCompanyName(?string $companyName): void
  451.     {
  452.         $this->companyName $companyName;
  453.     }
  454.     //    /**
  455.     //     * @return string|null
  456.     //     */
  457.     //    public function getTypeOfProfessional(): ?string
  458.     //    {
  459.     //        return $this->typeOfProfessional;
  460.     //    }
  461.     //
  462.     //    /**
  463.     //     * @param string|null $typeOfProfessional
  464.     //     */
  465.     //    public function setTypeOfProfessional(?string $typeOfProfessional): void
  466.     //    {
  467.     //        $this->typeOfProfessional = $typeOfProfessional;
  468.     //    }
  469.     /**
  470.      * @return Collection|null
  471.      */
  472.     public function getCart(): ?Collection
  473.     {
  474.         return $this->cart;
  475.     }
  476.     /**
  477.      * @param Collection|null $cart
  478.      */
  479.     public function setCart(?Collection $cart): void
  480.     {
  481.         $this->cart $cart;
  482.     }
  483.     /**
  484.      * @var string The hashed password
  485.      */
  486.     #[ORM\Column]
  487.     private ?string $password null;
  488.     /**
  489.      * @var string|null Temporary plain password for form input (not persisted)
  490.      */
  491.     private ?string $plainPassword null;
  492.     /**
  493.      * @var string|null Temporary plain password confirmation for form input (not persisted)
  494.      */
  495.     private ?string $plainPasswordConfirm null;
  496.     public function getId(): ?int
  497.     {
  498.         return $this->id;
  499.     }
  500.     public function getEmail(): ?string
  501.     {
  502.         return $this->email;
  503.     }
  504.     public function setEmail(string $email): self
  505.     {
  506.         $this->email $email;
  507.         return $this;
  508.     }
  509.     /**
  510.      * A visual identifier that represents this user.
  511.      *
  512.      * @see UserInterface
  513.      */
  514.     public function getUserIdentifier(): string
  515.     {
  516.         return (string) $this->email;
  517.     }
  518.     /**
  519.      * @see UserInterface
  520.      */
  521.     public function getRoles(): array
  522.     {
  523.         $roles $this->roles;
  524.         // guarantee every user at least has ROLE_USER
  525.         $roles[] = 'ROLE_USER';
  526.         return array_unique($roles);
  527.     }
  528.     public function setRoles(array $roles): self
  529.     {
  530.         $this->roles $roles;
  531.         return $this;
  532.     }
  533.     /**
  534.      * @see PasswordAuthenticatedUserInterface
  535.      */
  536.     public function getPassword(): string
  537.     {
  538.         return $this->password;
  539.     }
  540.     public function setPassword(string $password): self
  541.     {
  542.         $this->password $password;
  543.         return $this;
  544.     }
  545.     /**
  546.      * @see UserInterface
  547.      */
  548.     public function eraseCredentials()
  549.     {
  550.         // If you store any temporary, sensitive data on the user, clear it here
  551.         $this->plainPassword null;
  552.         $this->plainPasswordConfirm null;
  553.     }
  554.     public function getPlainPassword(): ?string
  555.     {
  556.         return $this->plainPassword;
  557.     }
  558.     public function setPlainPassword(?string $plainPassword): self
  559.     {
  560.         $this->plainPassword $plainPassword;
  561.         return $this;
  562.     }
  563.     public function getPlainPasswordConfirm(): ?string
  564.     {
  565.         return $this->plainPasswordConfirm;
  566.     }
  567.     public function setPlainPasswordConfirm(?string $plainPasswordConfirm): self
  568.     {
  569.         $this->plainPasswordConfirm $plainPasswordConfirm;
  570.         return $this;
  571.     }
  572.     public function getResetToken(): ?string
  573.     {
  574.         return $this->resetToken;
  575.     }
  576.     public function setResetToken(?string $resetToken): self
  577.     {
  578.         $this->resetToken $resetToken;
  579.         return $this;
  580.     }
  581.     public function getResetTokenExpiresAt(): ?\DateTimeInterface
  582.     {
  583.         return $this->resetTokenExpiresAt;
  584.     }
  585.     public function setResetTokenExpiresAt(?\DateTimeInterface $resetTokenExpiresAt): self
  586.     {
  587.         $this->resetTokenExpiresAt $resetTokenExpiresAt;
  588.         return $this;
  589.     }
  590.     public function __toString(): string
  591.     {
  592.         return $this->email ?? '';
  593.     }
  594.     public function getTvaNumbersAsString(): string
  595.     {
  596.         $tvas = [];
  597.         foreach ($this->AdditionalCompanyInformation as $info) {
  598.             // Assurez-vous que l'entité AdditionalCompanyInformation a une méthode getTva()
  599.             $tvas[] = $info->getTva();
  600.         }
  601.         return implode(", "$tvas);
  602.     }
  603.     public function getCompanyNameFromAdditionalInfo(): ?string
  604.     {
  605.         if ($this->AdditionalCompanyInformation && $this->AdditionalCompanyInformation->count() > 0) {
  606.             $firstInfo $this->AdditionalCompanyInformation->first();
  607.             return $firstInfo $firstInfo->getCompanyName() : null;
  608.         }
  609.         return null;
  610.     }
  611.     public function getMercatorIdFromAdditionalInfo(): ?string
  612.     {
  613.         if ($this->AdditionalCompanyInformation && $this->AdditionalCompanyInformation->count() > 0) {
  614.             $firstInfo $this->AdditionalCompanyInformation->first();
  615.             return $firstInfo $firstInfo->getIdClientMercator() : null;
  616.         }
  617.         return null;
  618.     }
  619.     public function setMercatorIdFromAdditionalInfo(?string $mercatorId): void
  620.     {
  621.         if ($this->AdditionalCompanyInformation && $this->AdditionalCompanyInformation->count() > 0) {
  622.             $firstInfo $this->AdditionalCompanyInformation->first();
  623.             if ($firstInfo) {
  624.                 $firstInfo->setIdClientMercator($mercatorId);
  625.             }
  626.         }
  627.     }
  628. }