src/Entity/User.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. /**
  12.  * @ORM\Entity(repositoryClass=UserRepository::class)
  13.  * @UniqueEntity(fields={"email"}, message="Il existe déjà un compte avec cette adresse.")
  14.  */
  15. class User implements UserInterfacePasswordAuthenticatedUserInterface {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=180, unique=true)
  24.      *
  25.      */
  26.     private $email;
  27.     /**
  28.      * @ORM\Column(type="json")
  29.      */
  30.     private $roles = array();
  31.     /**
  32.      * @var string The hashed password
  33.      * @ORM\Column(type="string")
  34.      */
  35.     private $password;
  36.     /**
  37.     * @ORM\Column(type="datetime")
  38.     * @Gedmo\Timestampable(on="create")
  39.     */
  40.     private $createdAt;
  41.     /**
  42.      * @ORM\Column(type="datetime")
  43.      * @Gedmo\Timestampable(on="update")
  44.      */
  45.     private $updatedAt;
  46.     /**
  47.      * @ORM\Column(type="string", length=50, nullable=true)
  48.      */
  49.     private $nom;
  50.     /**
  51.      * @ORM\Column(type="string", length=50, nullable=true)
  52.      */
  53.     private $prenom;
  54.     /**
  55.      * @ORM\Column(type="date", nullable=true)
  56.      */
  57.     private $naissance;
  58.     /**
  59.      * @ORM\Column(type="string", length=5, nullable=true)
  60.      */
  61.     private $cp;
  62.     /**
  63.      * @ORM\Column(type="string", length=10, nullable=true)
  64.      */
  65.     private $telephone;
  66.     /**
  67.      * @ORM\Column(type="integer")
  68.      */
  69.     private $isVerified false;
  70.     /**
  71.      * @ORM\Column(type="integer", options={"comment": "0: demande en cours, 1: approuvée, 2: refusée","default":0})
  72.      */
  73.     private $isApprouved false;
  74.     /**
  75.      * @ORM\Column(type="boolean")
  76.      */
  77.     private $isSuspend false;
  78.     /**
  79.      * @ORM\OneToMany(targetEntity=UserEleveDocument::class, mappedBy="users", orphanRemoval=true, cascade={"persist", "remove"})
  80.      */
  81.     private $documents;
  82.     /**
  83.      * @ORM\OneToMany(targetEntity=ShopPanier::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "remove"})
  84.      */
  85.     private $shopPaniers;
  86.     /**
  87.      * @ORM\OneToMany(targetEntity=ShopOrder::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "remove"})
  88.      * @ORM\OrderBy({"createdAt" = "DESC"})
  89.      */
  90.     private $shopOrders;
  91.     /**
  92.      * @ORM\OneToMany(targetEntity=ShopUserAdress::class, mappedBy="user", cascade={"persist", "remove"})
  93.      */
  94.     private $shopUserAdresses;
  95.     /**
  96.      * @ORM\OneToMany(targetEntity=UserEleveCredit::class, mappedBy="user", cascade={"persist", "remove"})
  97.      */
  98.     private $UserEleveCredits;
  99.     /**
  100.      * @ORM\OneToMany(targetEntity=ShopOrderProductConsommation::class, mappedBy="user", cascade={"persist", "remove"})
  101.      */
  102.     private $ShopOrderProductConsommations;
  103.     /**
  104.      * @ORM\Column(type="string", length=255)
  105.      */
  106.     private $ville;
  107.     /**
  108.      * @ORM\OneToMany(targetEntity=UserEnseignantDocument::class, mappedBy="user", orphanRemoval=true, cascade={"remove"})
  109.      */
  110.     private $userEnseignantDocuments;
  111.     /**
  112.      * @ORM\OneToOne(targetEntity=UserEnseignantAccountDetail::class, mappedBy="user", cascade={"persist"})
  113.      */
  114.     private $userEnseignantAccountDetail;
  115.     /**
  116.      * @ORM\OneToMany(targetEntity=UserEnseignantAccountVehicule::class, mappedBy="user", orphanRemoval=true, cascade={"remove"})
  117.      */
  118.     private $userEnseignantAccountVehicules;
  119.     /**
  120.      * @ORM\Column(type="string", length=25, nullable=true)
  121.      */
  122.     private $dpt;
  123.     /**
  124.      * @ORM\OneToMany(targetEntity=ActiviteDisponibilite::class, mappedBy="user", orphanRemoval=true, cascade={"remove"})
  125.      */
  126.     private $activiteDisponibilites;
  127.     /**
  128.      * @ORM\OneToMany(targetEntity=ActiviteDisponibiliteInscription::class, mappedBy="user", orphanRemoval=true, cascade={"remove"})
  129.      */
  130.     private $activiteDisponibiliteInscriptions;
  131.     /**
  132.      * @ORM\OneToMany(targetEntity=UserEnseignantLieu::class, mappedBy="user", orphanRemoval=true)
  133.      */
  134.     private $userEnseignantLieux;
  135.     /**
  136.      * @ORM\Column(type="string", length=255, nullable=true)
  137.      */
  138.     private $reference;
  139.     /**
  140.      * @ORM\OneToMany(targetEntity=UserEleveCreditConsommation::class, mappedBy="user", orphanRemoval=true, cascade={"remove"})
  141.      */
  142.     private $userEleveCreditConsommations;
  143.     /**
  144.      * @ORM\OneToMany(targetEntity=LivretEvaluation::class, mappedBy="eleve", orphanRemoval=true, cascade={"remove"})
  145.      */
  146.     private $livretEvaluations;
  147.     /**
  148.      * @ORM\OneToMany(targetEntity=LivretEstimation::class, mappedBy="eleve", cascade={"remove"})
  149.      */
  150.     private $estimations;
  151.     /**
  152.      * @ORM\OneToMany(targetEntity=UserEnseignantFacture::class, mappedBy="enseignant", cascade={"remove"})
  153.      */
  154.     private $factures;
  155.     /**
  156.      * @ORM\Column(type="string", unique=true, nullable=true)
  157.      */
  158.     private $apiToken;
  159.     /**
  160.      * @ORM\Column(type="datetime", nullable=true)
  161.      */
  162.     private $deletedAt;
  163.     public function __construct() {
  164.         $this->documents = new ArrayCollection();
  165.         $this->shopPaniers = new ArrayCollection();
  166.         $this->shopOrders = new ArrayCollection();
  167.         $this->shopUserAdresses = new ArrayCollection();
  168.         $this->UserEleveCredits = new ArrayCollection();
  169.         $this->ShopOrderProductConsommations = new ArrayCollection();
  170.         $this->userEnseignantDocuments = new ArrayCollection();
  171.         $this->userEnseignantAccountVehicules = new ArrayCollection();
  172.         $this->activiteDisponibilites = new ArrayCollection();
  173.         $this->activiteDisponibiliteInscriptions = new ArrayCollection();
  174.         $this->userEnseignantLieux = new ArrayCollection();
  175.         $this->userEleveCreditConsommations = new ArrayCollection();
  176.         $this->livretEvaluations = new ArrayCollection();
  177.         $this->estimations = new ArrayCollection();
  178.         $this->factures = new ArrayCollection();
  179.     }
  180.     public function getId(): ?int {
  181.         return $this->id;
  182.     }
  183.     public function getEmail(): ?string {
  184.         return $this->email;
  185.     }
  186.     public function setEmail(string $email): self {
  187.         $this->email $email;
  188.                                                                                                                                                                                                                                                                                     
  189.         return $this;
  190.     }
  191.     /**
  192.      * A visual identifier that represents this user.
  193.      *
  194.      * @see UserInterface
  195.      */
  196.     public function getUserIdentifier(): string {
  197.         return (string) $this->email;
  198.     }
  199.     /**
  200.      * @see UserInterface
  201.      */
  202.     public function getRoles(): array {
  203.         $roles $this->roles;
  204.         // guarantee every user at least has ROLE_USER
  205.         $roles[] = 'ROLE_USER';
  206.                                                                                                                                                                                                                                                                                     
  207.         return array_unique($roles);
  208.     }
  209.     public function setRoles(array $roles): self {
  210.         $this->roles $roles;
  211.                                                                                                                                                                                                                                                                                     
  212.         return $this;
  213.     }
  214.     /**
  215.      * @see PasswordAuthenticatedUserInterface
  216.      */
  217.     public function getPassword(): string {
  218.         return $this->password;
  219.     }
  220.     public function setPassword(string $password): self {
  221.         $this->password $password;
  222.                                                                                                                                                                                                                                                                                     
  223.         return $this;
  224.     }
  225.     /**
  226.      * Returning a salt is only needed, if you are not using a modern
  227.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  228.      *
  229.      * @see UserInterface
  230.      */
  231.     public function getSalt(): ?string {
  232.         return null;
  233.     }
  234.     /**
  235.      * @see UserInterface
  236.      */
  237.     public function eraseCredentials() {
  238.         // If you store any temporary, sensitive data on the user, clear it here
  239.                                                                                                                                                                                                                                                                                             // $this->plainPassword = null;
  240.     }
  241.     public function getUsername(): string {
  242.         return $this->email;
  243.     }
  244.     public function getCreatedAt(): ?\DateTimeInterface {
  245.         return $this->createdAt;
  246.     }
  247.     public function setCreatedAt(?\DateTimeInterface $createdAt): self {
  248.         $this->createdAt $createdAt;
  249.                                                                                                                                                                                                                                                                                     
  250.         return $this;
  251.     }
  252.     public function getUpdatedAt(): ?\DateTimeInterface {
  253.         return $this->updatedAt;
  254.     }
  255.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self {
  256.         $this->updatedAt $updatedAt;
  257.                                                                                                                                                                                                                                                                                     
  258.         return $this;
  259.     }
  260.     public function getNom(): ?string {
  261.         return $this->nom;
  262.     }
  263.     public function setNom(?string $nom): self {
  264.         $this->nom $nom;
  265.                                                                                                                                                                                                                         
  266.         return $this;
  267.     }
  268.     public function getPrenom(): ?string {
  269.         return $this->prenom;
  270.     }
  271.     public function setPrenom(?string $prenom): self {
  272.         $this->prenom $prenom;
  273.                                                                                                                                                                                                                         
  274.         return $this;
  275.     }
  276.     public function getNaissance(): ?\DateTimeInterface {
  277.         return $this->naissance;
  278.     }
  279.     public function setNaissance(?\DateTimeInterface $naissance): self {
  280.         $this->naissance $naissance;
  281.                                                                                                                                                                                                                         
  282.         return $this;
  283.     }
  284.     public function getCp(): ?string {
  285.         return $this->cp;
  286.     }
  287.     public function setCp(?string $cp): self {
  288.         $this->cp $cp;
  289.                                                                                                                                                                                                                         
  290.         return $this;
  291.     }
  292.     public function getTelephone(): ?string {
  293.         return $this->telephone;
  294.     }
  295.     public function setTelephone(?string $telephone): self {
  296.         if(strlen($telephone) > 10){
  297.             $telephone str_replace(' '''$telephone);
  298.         }
  299.         if(strlen($telephone) > 10){
  300.             $telephone str_replace('+33''0'$telephone);
  301.         }
  302.         $this->telephone $telephone;
  303.         return $this;
  304.     }
  305.     public function isVerified(): bool {
  306.         return $this->isVerified;
  307.     }
  308.     public function setIsVerified(bool $isVerified): self {
  309.         $this->isVerified $isVerified;
  310.                                                                                                                                                                                                                         
  311.         return $this;
  312.     }
  313.     public function isApprouved(): int {
  314.         return $this->isApprouved;
  315.     }
  316.     public function isDisapproved(): bool {
  317.         return $this->isApprouved == 2;
  318.     }
  319.     public function isApproved(): bool {
  320.         return $this->isApprouved == 1;
  321.     }
  322.     public function isPending(): bool {
  323.         return $this->isApprouved == 0;
  324.     }
  325.     public function setIsApprouved(int $isApprouved): self {
  326.         $this->isApprouved $isApprouved;
  327.                                                                                                                                                                                                                         
  328.         return $this;
  329.     }
  330.     public function isSuspend(): bool {
  331.         return $this->isSuspend;
  332.     }
  333.     public function setIsSuspend(bool $isSuspend): self {
  334.         $this->isSuspend $isSuspend;
  335.                                                                                                                                                                                                                         
  336.         return $this;
  337.     }
  338.     /**
  339.      * @return Collection|UserEleveDocument[]
  340.      */
  341.     public function getDocuments(): Collection {
  342.         return $this->documents;
  343.     }
  344.     public function addDocument(UserEleveDocument $document): self {
  345.         if (!$this->documents->contains($document)) {
  346.             $this->documents[] = $document;
  347.             $document->setUsers($this);
  348.         }
  349.                                                                                                                                                                                         
  350.         return $this;
  351.     }
  352.     public function removeDocument(UserEleveDocument $document): self {
  353.         if ($this->documents->removeElement($document)) {
  354.             // set the owning side to null (unless already changed)
  355.             if ($document->getUsers() === $this) {
  356.                 $document->setUsers(null);
  357.             }
  358.         }
  359.                                                                                                                                                                                         
  360.         return $this;
  361.     }
  362.     /**
  363.      * @return Collection|ShopPanier[]
  364.      */
  365.     public function getShopPaniers(): Collection {
  366.         return $this->shopPaniers;
  367.     }
  368.     public function addShopPanier(ShopPanier $shopPanier): self {
  369.         if (!$this->shopPaniers->contains($shopPanier)) {
  370.             $this->shopPaniers[] = $shopPanier;
  371.             $shopPanier->setUser($this);
  372.         }
  373.                                                                                                             
  374.         return $this;
  375.     }
  376.     public function removeShopPanier(ShopPanier $shopPanier): self {
  377.         if ($this->shopPaniers->removeElement($shopPanier)) {
  378.             // set the owning side to null (unless already changed)
  379.             if ($shopPanier->getUser() === $this) {
  380.                 $shopPanier->setUser(null);
  381.             }
  382.         }
  383.                                                                                                             
  384.         return $this;
  385.     }
  386.     /**
  387.      * @return Collection|ShopOrder[]
  388.      */
  389.     public function getShopOrders(): Collection {
  390.         return $this->shopOrders;
  391.     }
  392.     public function addShopOrder(ShopOrder $shopOrder): self {
  393.         if (!$this->shopOrders->contains($shopOrder)) {
  394.             $this->shopOrders[] = $shopOrder;
  395.             $shopOrder->setUser($this);
  396.         }
  397.                                                                                                             
  398.         return $this;
  399.     }
  400.     public function removeShopOrder(ShopOrder $shopOrder): self {
  401.         if ($this->shopOrders->removeElement($shopOrder)) {
  402.             // set the owning side to null (unless already changed)
  403.             if ($shopOrder->getUser() === $this) {
  404.                 $shopOrder->setUser(null);
  405.             }
  406.         }
  407.                                                                                                             
  408.         return $this;
  409.     }
  410.     /**
  411.      * @return Collection|ShopUserAdress[]
  412.      */
  413.     public function getShopUserAdresses(): Collection {
  414.         return $this->shopUserAdresses;
  415.     }
  416.     public function addShopUserAdress(ShopUserAdress $shopUserAdress): self {
  417.         if (!$this->shopUserAdresses->contains($shopUserAdress)) {
  418.             $this->shopUserAdresses[] = $shopUserAdress;
  419.             $shopUserAdress->setUser($this);
  420.         }
  421.                                                                                                             
  422.         return $this;
  423.     }
  424.     public function removeShopUserAdress(ShopUserAdress $shopUserAdress): self {
  425.         if ($this->shopUserAdresses->removeElement($shopUserAdress)) {
  426.             // set the owning side to null (unless already changed)
  427.             if ($shopUserAdress->getUser() === $this) {
  428.                 $shopUserAdress->setUser(null);
  429.             }
  430.         }
  431.                                                                                                             
  432.         return $this;
  433.     }
  434.     /**
  435.      * @return Collection|UserEleveCredit[]
  436.      */
  437.     public function getUserEleveCredits(): Collection {
  438.         return $this->UserEleveCredits;
  439.     }
  440.     public function addUserEleveCredit(UserEleveCredit $UserEleveCredit): self {
  441.         if (!$this->UserEleveCredits->contains($UserEleveCredit)) {
  442.             $this->UserEleveCredits[] = $UserEleveCredit;
  443.             $UserEleveCredit->setUser($this);
  444.         }
  445.                         
  446.         return $this;
  447.     }
  448.     public function removeUserEleveCredit(UserEleveCredit $UserEleveCredit): self {
  449.         if ($this->UserEleveCredits->removeElement($UserEleveCredit)) {
  450.             // set the owning side to null (unless already changed)
  451.             if ($UserEleveCredit->getUser() === $this) {
  452.                 $UserEleveCredit->setUser(null);
  453.             }
  454.         }
  455.                         
  456.         return $this;
  457.     }
  458.     public function getUserEleveCredit(ShopCategorie $Category): ?UserEleveCredit {
  459.         $UserEleveCredit $this->UserEleveCredits->filter(function($element) use($Category) {
  460.             return $element->getCategorie()->getId() == $Category->getId();
  461.         })->first();
  462.         if ($UserEleveCredit) {
  463.             return $UserEleveCredit;
  464.         }
  465.         return null;
  466.     }
  467.     /**
  468.      * @return Collection|ShopOrderProductConsommation[]
  469.      */
  470.     public function getShopOrderProductConsommations(): Collection {
  471.         return $this->ShopOrderProductConsommations;
  472.     }
  473.     public function addShopOrderProductConsommation(ShopOrderProductConsommation $ShopOrderProductConsommation): self {
  474.         if (!$this->ShopOrderProductConsommations->contains($ShopOrderProductConsommation)) {
  475.             $this->ShopOrderProductConsommations[] = $ShopOrderProductConsommation;
  476.             $ShopOrderProductConsommation->setUser($this);
  477.         }
  478.                         
  479.         return $this;
  480.     }
  481.     public function removeShopOrderProductConsommation(ShopOrderProductConsommation $ShopOrderProductConsommation): self {
  482.         if ($this->ShopOrderProductConsommations->removeElement($ShopOrderProductConsommation)) {
  483.             // set the owning side to null (unless already changed)
  484.             if ($ShopOrderProductConsommation->getUser() === $this) {
  485.                 $ShopOrderProductConsommation->setUser(null);
  486.             }
  487.         }
  488.                         
  489.         return $this;
  490.     }
  491.     public function getVille(): ?string {
  492.         return $this->ville;
  493.     }
  494.     public function setVille(string $ville): self {
  495.         $this->ville $ville;
  496.                         
  497.         return $this;
  498.     }
  499.     /**
  500.      * @return Collection|UserEnseignantDocument[]
  501.      */
  502.     public function getUserEnseignantDocuments(): Collection {
  503.         return $this->userEnseignantDocuments;
  504.     }
  505.     public function addUserEnseignantDocument(UserEnseignantDocument $userEnseignantDocument): self {
  506.         if (!$this->userEnseignantDocuments->contains($userEnseignantDocument)) {
  507.             $this->userEnseignantDocuments[] = $userEnseignantDocument;
  508.             $userEnseignantDocument->setUser($this);
  509.         }
  510.                         
  511.         return $this;
  512.     }
  513.     public function removeUserEnseignantDocument(UserEnseignantDocument $userEnseignantDocument): self {
  514.         if ($this->userEnseignantDocuments->removeElement($userEnseignantDocument)) {
  515.             // set the owning side to null (unless already changed)
  516.             if ($userEnseignantDocument->getUser() === $this) {
  517.                 $userEnseignantDocument->setUser(null);
  518.             }
  519.         }
  520.                         
  521.         return $this;
  522.     }
  523.     public function getDocument($doc): ?UserEnseignantDocument {
  524.         $elements $this->getUserEnseignantDocuments()->filter(function($Document) use ($doc) {return $Document->getDoc() == $doc;});
  525.         if(count($elements))
  526.         return $elements[0];
  527.         return null;
  528.     }
  529.     /**
  530.     * @return Collection|UserEnseignantAccountVehicule[]
  531.     */
  532.     public function getUserEnseignantAccountVehicules(): Collection {
  533.         return $this->userEnseignantAccountVehicules;
  534.     }
  535.     public function addUserEnseignantAccountVehicule(UserEnseignantAccountVehicule $userEnseignantAccountVehicule): self {
  536.         if (!$this->userEnseignantAccountVehicules->contains($userEnseignantAccountVehicule)) {
  537.             $this->userEnseignantAccountVehicules[] = $userEnseignantAccountVehicule;
  538.             $userEnseignantAccountVehicule->setUser($this);
  539.         }
  540.         return $this;
  541.     }
  542.     public function removeUserEnseignantAccountVehicule(UserEnseignantAccountVehicule $userEnseignantAccountVehicule): self {
  543.         if ($this->userEnseignantAccountVehicules->removeElement($userEnseignantAccountVehicule)) {
  544.             // set the owning side to null (unless already changed)
  545.             if ($userEnseignantAccountVehicule->getUser() === $this) {
  546.                 $userEnseignantAccountVehicule->setUser(null);
  547.             }
  548.         }
  549.         return $this;
  550.     }
  551.     public function getAccountDetail(): ?UserEnseignantAccountDetail {
  552.         return $this->getUserEnseignantAccountDetail();
  553.     }
  554.     public function getUserEnseignantAccountDetail(): ?UserEnseignantAccountDetail {
  555.         return $this->userEnseignantAccountDetail;
  556.     }
  557.     public function setUserEnseignantAccountDetail(UserEnseignantAccountDetail $userEnseignantAccountDetail): self {
  558.         // set the owning side of the relation if necessary
  559.         if ($userEnseignantAccountDetail->getUser() !== $this) {
  560.             $userEnseignantAccountDetail->setUser($this);
  561.         }
  562.         $this->userEnseignantAccountDetail $userEnseignantAccountDetail;
  563.         return $this;
  564.     }
  565.     public function getDpt(): ?string
  566.     {
  567.         return $this->dpt;
  568.     }
  569.     public function setDpt(?string $dpt): self
  570.     {
  571.         $this->dpt $dpt;
  572.         return $this;
  573.     }
  574.     /**
  575.      * @return Collection|ActiviteDisponibilite[]
  576.      */
  577.     public function getActiviteDisponibilites(): Collection
  578.     {
  579.         return $this->activiteDisponibilites;
  580.     }
  581.     public function addActiviteDisponibilite(ActiviteDisponibilite $activiteDisponibilite): self
  582.     {
  583.         if (!$this->activiteDisponibilites->contains($activiteDisponibilite)) {
  584.             $this->activiteDisponibilites[] = $activiteDisponibilite;
  585.             $activiteDisponibilite->setUser($this);
  586.         }
  587.         return $this;
  588.     }
  589.     public function removeActiviteDisponibilite(ActiviteDisponibilite $activiteDisponibilite): self
  590.     {
  591.         if ($this->activiteDisponibilites->removeElement($activiteDisponibilite)) {
  592.             // set the owning side to null (unless already changed)
  593.             if ($activiteDisponibilite->getUser() === $this) {
  594.                 $activiteDisponibilite->setUser(null);
  595.             }
  596.         }
  597.         return $this;
  598.     }
  599.     /**
  600.      * @return Collection|ActiviteDisponibiliteInscription[]
  601.      */
  602.     public function getActiviteDisponibiliteInscriptions(): Collection
  603.     {
  604.         return $this->activiteDisponibiliteInscriptions;
  605.     }
  606.     public function addActiviteDisponibiliteInscription(ActiviteDisponibiliteInscription $activiteDisponibiliteInscription): self
  607.     {
  608.         if (!$this->activiteDisponibiliteInscriptions->contains($activiteDisponibiliteInscription)) {
  609.             $this->activiteDisponibiliteInscriptions[] = $activiteDisponibiliteInscription;
  610.             $activiteDisponibiliteInscription->setUser($this);
  611.         }
  612.         return $this;
  613.     }
  614.     public function removeActiviteDisponibiliteInscription(ActiviteDisponibiliteInscription $activiteDisponibiliteInscription): self
  615.     {
  616.         if ($this->activiteDisponibiliteInscriptions->removeElement($activiteDisponibiliteInscription)) {
  617.             // set the owning side to null (unless already changed)
  618.             if ($activiteDisponibiliteInscription->getUser() === $this) {
  619.                 $activiteDisponibiliteInscription->setUser(null);
  620.             }
  621.         }
  622.         return $this;
  623.     }
  624.     /**
  625.      * @return Collection|UserEnseignantLieu[]
  626.      */
  627.     public function getUserEnseignantLieux(): Collection
  628.     {
  629.         return $this->userEnseignantLieux;
  630.     }
  631.     public function addUserEnseignantLieux(UserEnseignantLieu $userEnseignantLieux): self
  632.     {
  633.         if (!$this->userEnseignantLieux->contains($userEnseignantLieux)) {
  634.             $this->userEnseignantLieux[] = $userEnseignantLieux;
  635.             $userEnseignantLieux->setUser($this);
  636.         }
  637.         return $this;
  638.     }
  639.     public function removeUserEnseignantLieux(UserEnseignantLieu $userEnseignantLieux): self
  640.     {
  641.         if ($this->userEnseignantLieux->removeElement($userEnseignantLieux)) {
  642.             // set the owning side to null (unless already changed)
  643.             if ($userEnseignantLieux->getUser() === $this) {
  644.                 $userEnseignantLieux->setUser(null);
  645.             }
  646.         }
  647.         return $this;
  648.     }
  649.     public function getReference(): ?string
  650.     {
  651.         return $this->reference;
  652.     }
  653.     public function setReference(?string $reference): self
  654.     {
  655.         $this->reference $reference;
  656.         return $this;
  657.     }
  658.     public function getDir(): string {
  659.         $path realpath(__DIR__ '/../../');
  660.         $path .= '/var';
  661.         $path .= '/user';
  662.         $slugger = new \Symfony\Component\String\Slugger\AsciiSlugger;
  663.         $path .= '/'.$slugger->slug($this->getUserIdentifier());
  664.         return $path;
  665.     }
  666.     /**
  667.      * @return Collection<int, UserEleveCreditConsommation>
  668.      */
  669.     public function getUserEleveCreditConsommations(): Collection
  670.     {
  671.         return $this->userEleveCreditConsommations;
  672.     }
  673.     public function addUserEleveCreditConsommation(UserEleveCreditConsommation $userEleveCreditConsommation): self
  674.     {
  675.         if (!$this->userEleveCreditConsommations->contains($userEleveCreditConsommation)) {
  676.             $this->userEleveCreditConsommations[] = $userEleveCreditConsommation;
  677.             $userEleveCreditConsommation->setUser($this);
  678.         }
  679.         return $this;
  680.     }
  681.     public function removeUserEleveCreditConsommation(UserEleveCreditConsommation $userEleveCreditConsommation): self
  682.     {
  683.         if ($this->userEleveCreditConsommations->removeElement($userEleveCreditConsommation)) {
  684.             // set the owning side to null (unless already changed)
  685.             if ($userEleveCreditConsommation->getUser() === $this) {
  686.                 $userEleveCreditConsommation->setUser(null);
  687.             }
  688.         }
  689.         return $this;
  690.     }
  691.     public function isRole(string $role):bool {
  692.         return in_array('ROLE_'.strtoupper($role), $this->getRoles());
  693.     }
  694.     public function isEleve():bool {
  695.         return $this->isRole('eleve');
  696.     }
  697.     public function isProf():bool {
  698.         return $this->isRole('prof');
  699.     }
  700.     public function isAdmin():bool {
  701.         return $this->isRole('admin')||$this->isRole('super_admin');
  702.     }
  703.     public function isSalarie():bool {
  704.         if(!$this->isProf())return false;
  705.         if(!$this->getUserEnseignantAccountDetail())return false;
  706.         return $this->getUserEnseignantAccountDetail()->isSalarie();
  707.     }
  708.     public function isIndependant():bool {
  709.         if(!$this->isProf())return false;
  710.         if(!$this->getUserEnseignantAccountDetail())return false;
  711.         return $this->getUserEnseignantAccountDetail()->isIndependant();
  712.     }
  713.     public function getType() : ?string
  714.     {
  715.         if($this->isSalarie())return 'salarie';
  716.         if($this->isIndependant())return 'independant';
  717.         return null;
  718.     }
  719.     /**
  720.      * @return Collection<int, LivretEvaluation>
  721.      */
  722.     public function getLivretEvaluations(): Collection
  723.     {
  724.         return $this->livretEvaluations;
  725.     }
  726.     public function addLivretEvaluation(LivretEvaluation $livretEvaluation): self
  727.     {
  728.         if (!$this->livretEvaluations->contains($livretEvaluation)) {
  729.             $this->livretEvaluations[] = $livretEvaluation;
  730.             $livretEvaluation->setEleve($this);
  731.         }
  732.         return $this;
  733.     }
  734.     public function removeLivretEvaluation(LivretEvaluation $livretEvaluation): self
  735.     {
  736.         if ($this->livretEvaluations->removeElement($livretEvaluation)) {
  737.             // set the owning side to null (unless already changed)
  738.             if ($livretEvaluation->getEleve() === $this) {
  739.                 $livretEvaluation->setEleve(null);
  740.             }
  741.         }
  742.         return $this;
  743.     }
  744.     /**
  745.      * @return Collection<int, LivretEstimation>
  746.      */
  747.     public function getEstimations(): Collection
  748.     {
  749.         return $this->estimations;
  750.     }
  751.     public function addEstimation(LivretEstimation $estimation): self
  752.     {
  753.         if (!$this->estimations->contains($estimation)) {
  754.             $this->estimations[] = $estimation;
  755.             $estimation->setEleve($this);
  756.         }
  757.         return $this;
  758.     }
  759.     public function removeEstimation(LivretEstimation $estimation): self
  760.     {
  761.         if ($this->estimations->removeElement($estimation)) {
  762.             // set the owning side to null (unless already changed)
  763.             if ($estimation->getEleve() === $this) {
  764.                 $estimation->setEleve(null);
  765.             }
  766.         }
  767.         return $this;
  768.     }
  769.     /**
  770.      * @return Collection<int, UserEnseignantFacture>
  771.      */
  772.     public function getFactures(): Collection
  773.     {
  774.         return $this->factures;
  775.     }
  776.     public function addFacture(UserEnseignantFacture $facture): self
  777.     {
  778.         if (!$this->factures->contains($facture)) {
  779.             $this->factures[] = $facture;
  780.             $facture->setEnseignant($this);
  781.         }
  782.         return $this;
  783.     }
  784.     public function removeFacture(UserEnseignantFacture $facture): self
  785.     {
  786.         if ($this->factures->removeElement($facture)) {
  787.             // set the owning side to null (unless already changed)
  788.             if ($facture->getEnseignant() === $this) {
  789.                 $facture->setEnseignant(null);
  790.             }
  791.         }
  792.         return $this;
  793.     }
  794.     public function getFacture(\DateTimeInterface $periode_debut\DateTimeInterface $periode_fin): ?UserEnseignantFacture
  795.     {
  796.         $Facture $this->factures->filter(function($element) use($periode_debut$periode_fin) {
  797.             if($element->getExport())return false;
  798.             if($element->getPeriodeDebut()->format('c') != $periode_debut->format('c'))return false;
  799.             if($element->getPeriodeFin()->format('c') != $periode_fin->format('c'))return false;
  800.             return true;
  801.         })->first();
  802.         if ($Facture) {
  803.             return $Facture;
  804.         }
  805.         return null;
  806.     }
  807.     public function getApiToken(): ?string
  808.     {
  809.         return $this->apiToken;
  810.     }
  811.     public function setApiToken(?string $apiToken): self
  812.     {
  813.         $this->apiToken $apiToken;
  814.         return $this;
  815.     }
  816.     public function isDeleted(): bool
  817.     {
  818.         return ($this->deletedAt !== null);
  819.     }
  820.     public function getDeletedAt(): ?\DateTimeInterface
  821.     {
  822.         return $this->deletedAt;
  823.     }
  824.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  825.     {
  826.         $this->deletedAt $deletedAt;
  827.         return $this;
  828.     }
  829. }