src/Entity/LocataireUser.php line 23

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use App\Traits\TimeStampTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  11. use Symfony\Component\Security\Core\User\UserInterface;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. #[ORM\Table(name'locataire_user')]
  14. #[ORM\Entity(repositoryClassUserRepository::class)]
  15. #[ORM\HasLifecycleCallbacks]
  16. #[UniqueEntity(
  17.     fields: ['username'],
  18.     message'Ce nom utilisateur est déjà pris.',
  19. )]
  20. class LocataireUser implements UserInterfacePasswordAuthenticatedUserInterface
  21. {
  22.     use TimeStampTrait;
  23.     #[ORM\Id]
  24.     #[ORM\GeneratedValue]
  25.     #[ORM\Column]
  26.     private ?int $id null;
  27.     #[ORM\Column(length180uniquetrue)]
  28.     private ?string $username null;
  29.     /**
  30.      * @var string The hashed password
  31.      */
  32.     #[ORM\Column]
  33.     private ?string $password null;
  34.     #[ORM\ManyToOne(inversedBy'users')]
  35.     private ?Role $role null;
  36.     #[ORM\Column(length50nullabletrue)]
  37.     private ?string $name null;
  38.     #[ORM\Column(length50nullabletrue)]
  39.     private ?string $lastname null;
  40.     #[ORM\Column(length100nullabletrue)]
  41.     private ?string $code null;
  42.     #[ORM\Column(nullabletrue)]
  43.     private ?bool $status null;
  44.     #[ORM\Column(nullabletrue)]
  45.     private ?bool $reset null;
  46.     #[ORM\Column(length25nullabletrue)]
  47.     private ?string $sexe null;
  48.     #[ORM\Column(length25nullabletrue)]
  49.     private ?string $phone null;
  50.     #[ORM\Column(length150nullabletrue)]
  51.     private ?string $picture null;
  52.     #[ORM\OneToMany(mappedBy'createdBy'targetEntityLocation::class)]
  53.     private Collection $locations;
  54.     #[ORM\ManyToOne(inversedBy'users')]
  55.     private ?Entreprise $entreprise null;
  56.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'users')]
  57.     private ?self $createdBy null;
  58.     #[ORM\OneToMany(mappedBy'createdBy'targetEntityself::class)]
  59.     private Collection $users;
  60.     #[ORM\Column(nullabletrue)]
  61.     private ?bool $notif null;
  62.     /**
  63.      * @Assert\NotBlank()
  64.      * @Assert\Email()
  65.      */
  66.     #[ORM\Column(length100nullabletrue)]
  67.     private ?string $email null;
  68.     #[ORM\Column(length50nullabletrue)]
  69.     private ?string $profil null;
  70.     #[ORM\OneToMany(mappedBy'createdBy'targetEntityCountry::class)]
  71.     private Collection $countries;
  72.     #[ORM\OneToMany(mappedBy'createdBy'targetEntityLog::class)]
  73.     private Collection $logs;
  74.     #[ORM\OneToMany(mappedBy'createdBy'targetEntityTemplate::class)]
  75.     private Collection $templates;
  76.     #[ORM\Column(nullabletrue)]
  77.     private ?int $level null;
  78.     #[ORM\OneToMany(mappedBy'createdBy'targetEntityIncident::class)]
  79.     private Collection $incidents;
  80.     #[ORM\OneToMany(mappedBy'createdBy'targetEntityIncidentUpdate::class)]
  81.     private Collection $incidentUpdates;
  82.     #[ORM\OneToMany(mappedBy'createdBy'targetEntityService::class)]
  83.     private Collection $services;
  84.     #[ORM\Column(length100nullabletrue)]
  85.     private ?string $adress null;
  86.     #[ORM\Column(length50nullabletrue)]
  87.     private ?string $city null;
  88.     #[ORM\Column(length50nullabletrue)]
  89.     private ?string $province null;
  90.     #[ORM\ManyToOne(inversedBy'users')]
  91.     private ?Country $country null;
  92.     #[ORM\ManyToOne(inversedBy'locataireUsers')]
  93.     private ?Locataire $locataire null;
  94.     #[ORM\Column(length25nullabletrue)]
  95.     private ?string $mode null;
  96.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  97.     private ?\DateTimeInterface $lastAction null;
  98.     public function __construct()
  99.     {
  100.         $this->locations = new ArrayCollection();
  101.         $this->users = new ArrayCollection();
  102.         $this->countries = new ArrayCollection();
  103.         $this->logs = new ArrayCollection();
  104.         $this->templates = new ArrayCollection();
  105.         $this->incidents = new ArrayCollection();
  106.         $this->incidentUpdates = new ArrayCollection();
  107.         $this->services = new ArrayCollection();
  108.     }
  109.     public function getId(): ?int
  110.     {
  111.         return $this->id;
  112.     }
  113.     public function getUsername(): ?string
  114.     {
  115.         return $this->username;
  116.     }
  117.     public function setUsername(string $username): self
  118.     {
  119.         $this->username $username;
  120.         return $this;
  121.     }
  122.     /**
  123.      * A visual identifier that represents this user.
  124.      *
  125.      * @see UserInterface
  126.      */
  127.     public function getUserIdentifier(): string
  128.     {
  129.         return (string) $this->username;
  130.     }
  131.     /**
  132.      * @see UserInterface
  133.      */
  134.     public function getRoles(): array
  135.     {
  136.         $rs = [];
  137.         $rs[] = 'ROLE_ADMIN';
  138.         if ($this->role != null) {
  139.             foreach ($this->role->getPrivilege() as $role)
  140.             {
  141.                 $rs[] = 'ROLE_'.$role->getlibelle();
  142.             }
  143.         }
  144.         return $rs;
  145.     }
  146.     /**
  147.      * @see PasswordAuthenticatedUserInterface
  148.      */
  149.     public function getPassword(): string
  150.     {
  151.         return $this->password;
  152.     }
  153.     public function setPassword(string $password): self
  154.     {
  155.         $this->password $password;
  156.         return $this;
  157.     }
  158.     /**
  159.      * @see UserInterface
  160.      */
  161.     public function eraseCredentials()
  162.     {
  163.         // If you store any temporary, sensitive data on the user, clear it here
  164.         // $this->plainPassword = null;
  165.     }
  166.     public function getRole(): ?Role
  167.     {
  168.         return $this->role;
  169.     }
  170.     public function setRole(?Role $role): self
  171.     {
  172.         $this->role $role;
  173.         return $this;
  174.     }
  175.     public function getName(): ?string
  176.     {
  177.         return $this->name;
  178.     }
  179.     public function setName(?string $name): self
  180.     {
  181.         $this->name $name;
  182.         return $this;
  183.     }
  184.     public function getLastname(): ?string
  185.     {
  186.         return $this->lastname;
  187.     }
  188.     public function setLastname(?string $lastname): self
  189.     {
  190.         $this->lastname $lastname;
  191.         return $this;
  192.     }
  193.     public function getCode(): ?string
  194.     {
  195.         return $this->code;
  196.     }
  197.     public function setCode(?string $code): self
  198.     {
  199.         $this->code $code;
  200.         return $this;
  201.     }
  202.     public function isStatus(): ?bool
  203.     {
  204.         return $this->status;
  205.     }
  206.     public function setStatus(?bool $status): self
  207.     {
  208.         $this->status $status;
  209.         return $this;
  210.     }
  211.     public function isReset(): ?bool
  212.     {
  213.         return $this->reset;
  214.     }
  215.     public function setReset(?bool $reset): self
  216.     {
  217.         $this->reset $reset;
  218.         return $this;
  219.     }
  220.     public function __toString(): string
  221.     {
  222.         return $this->name ' ' $this->lastname;
  223.     }
  224.     public function getSexe(): ?string
  225.     {
  226.         return $this->sexe;
  227.     }
  228.     public function setSexe(?string $sexe): static
  229.     {
  230.         $this->sexe $sexe;
  231.         return $this;
  232.     }
  233.     public function getPhone(): ?string
  234.     {
  235.         return $this->phone;
  236.     }
  237.     public function setPhone(?string $phone): static
  238.     {
  239.         $this->phone $phone;
  240.         return $this;
  241.     }
  242.     public function getPicture(): ?string
  243.     {
  244.         return $this->picture;
  245.     }
  246.     public function setPicture(?string $picture): static
  247.     {
  248.         $this->picture $picture;
  249.         return $this;
  250.     }
  251.     /**
  252.      * @return Collection<int, Location>
  253.      */
  254.     public function getLocations(): Collection
  255.     {
  256.         return $this->locations;
  257.     }
  258.     public function addLocation(Location $location): static
  259.     {
  260.         if (!$this->locations->contains($location)) {
  261.             $this->locations->add($location);
  262.             $location->setCreatedBy($this);
  263.         }
  264.         return $this;
  265.     }
  266.     public function removeLocation(Location $location): static
  267.     {
  268.         if ($this->locations->removeElement($location)) {
  269.             // set the owning side to null (unless already changed)
  270.             if ($location->getCreatedBy() === $this) {
  271.                 $location->setCreatedBy(null);
  272.             }
  273.         }
  274.         return $this;
  275.     }
  276.     public function getEntreprise(): ?Entreprise
  277.     {
  278.         return $this->entreprise;
  279.     }
  280.     public function setEntreprise(?Entreprise $entreprise): static
  281.     {
  282.         $this->entreprise $entreprise;
  283.         return $this;
  284.     }
  285.     public function getCreatedBy(): ?self
  286.     {
  287.         return $this->createdBy;
  288.     }
  289.     public function setCreatedBy(?self $createdBy): static
  290.     {
  291.         $this->createdBy $createdBy;
  292.         return $this;
  293.     }
  294.     /**
  295.      * @return Collection<int, self>
  296.      */
  297.     public function getUsers(): Collection
  298.     {
  299.         return $this->users;
  300.     }
  301.     public function addUser(self $user): static
  302.     {
  303.         if (!$this->users->contains($user)) {
  304.             $this->users->add($user);
  305.             $user->setCreatedBy($this);
  306.         }
  307.         return $this;
  308.     }
  309.     public function removeUser(self $user): static
  310.     {
  311.         if ($this->users->removeElement($user)) {
  312.             // set the owning side to null (unless already changed)
  313.             if ($user->getCreatedBy() === $this) {
  314.                 $user->setCreatedBy(null);
  315.             }
  316.         }
  317.         return $this;
  318.     }
  319.     public function isNotif(): ?bool
  320.     {
  321.         return $this->notif;
  322.     }
  323.     public function setNotif(?bool $notif): static
  324.     {
  325.         $this->notif $notif;
  326.         return $this;
  327.     }
  328.     public function getEmail(): ?string
  329.     {
  330.         return $this->email;
  331.     }
  332.     public function setEmail(?string $email): static
  333.     {
  334.         $this->email $email;
  335.         return $this;
  336.     }
  337.     public function getProfil(): ?string
  338.     {
  339.         return $this->profil;
  340.     }
  341.     public function setProfil(?string $profil): static
  342.     {
  343.         $this->profil $profil;
  344.         return $this;
  345.     }
  346.     /**
  347.      * @return Collection<int, Country>
  348.      */
  349.     public function getCountries(): Collection
  350.     {
  351.         return $this->countries;
  352.     }
  353.     public function addCountry(Country $country): static
  354.     {
  355.         if (!$this->countries->contains($country)) {
  356.             $this->countries->add($country);
  357.             $country->setCreatedBy($this);
  358.         }
  359.         return $this;
  360.     }
  361.     public function removeCountry(Country $country): static
  362.     {
  363.         if ($this->countries->removeElement($country)) {
  364.             // set the owning side to null (unless already changed)
  365.             if ($country->getCreatedBy() === $this) {
  366.                 $country->setCreatedBy(null);
  367.             }
  368.         }
  369.         return $this;
  370.     }
  371.     /**
  372.      * @return Collection<int, Log>
  373.      */
  374.     public function getLogs(): Collection
  375.     {
  376.         return $this->logs;
  377.     }
  378.     public function addLog(Log $log): static
  379.     {
  380.         if (!$this->logs->contains($log)) {
  381.             $this->logs->add($log);
  382.             $log->setCreatedBy($this);
  383.         }
  384.         return $this;
  385.     }
  386.     public function removeLog(Log $log): static
  387.     {
  388.         if ($this->logs->removeElement($log)) {
  389.             // set the owning side to null (unless already changed)
  390.             if ($log->getCreatedBy() === $this) {
  391.                 $log->setCreatedBy(null);
  392.             }
  393.         }
  394.         return $this;
  395.     }
  396.     /**
  397.      * @return Collection<int, Template>
  398.      */
  399.     public function getTemplates(): Collection
  400.     {
  401.         return $this->templates;
  402.     }
  403.     public function addTemplate(Template $template): static
  404.     {
  405.         if (!$this->templates->contains($template)) {
  406.             $this->templates->add($template);
  407.             $template->setCreatedBy($this);
  408.         }
  409.         return $this;
  410.     }
  411.     public function removeTemplate(Template $template): static
  412.     {
  413.         if ($this->templates->removeElement($template)) {
  414.             // set the owning side to null (unless already changed)
  415.             if ($template->getCreatedBy() === $this) {
  416.                 $template->setCreatedBy(null);
  417.             }
  418.         }
  419.         return $this;
  420.     }
  421.     public function getLevel(): ?int
  422.     {
  423.         return $this->level;
  424.     }
  425.     public function setLevel(?int $level): static
  426.     {
  427.         $this->level $level;
  428.         return $this;
  429.     }
  430.     /**
  431.      * @return Collection<int, Incident>
  432.      */
  433.     public function getIncidents(): Collection
  434.     {
  435.         return $this->incidents;
  436.     }
  437.     public function addIncident(Incident $incident): static
  438.     {
  439.         if (!$this->incidents->contains($incident)) {
  440.             $this->incidents->add($incident);
  441.             $incident->setCreatedBy($this);
  442.         }
  443.         return $this;
  444.     }
  445.     public function removeIncident(Incident $incident): static
  446.     {
  447.         if ($this->incidents->removeElement($incident)) {
  448.             // set the owning side to null (unless already changed)
  449.             if ($incident->getCreatedBy() === $this) {
  450.                 $incident->setCreatedBy(null);
  451.             }
  452.         }
  453.         return $this;
  454.     }
  455.     /**
  456.      * @return Collection<int, IncidentUpdate>
  457.      */
  458.     public function getIncidentUpdates(): Collection
  459.     {
  460.         return $this->incidentUpdates;
  461.     }
  462.     public function addIncidentUpdate(IncidentUpdate $incidentUpdate): static
  463.     {
  464.         if (!$this->incidentUpdates->contains($incidentUpdate)) {
  465.             $this->incidentUpdates->add($incidentUpdate);
  466.             $incidentUpdate->setCreatedBy($this);
  467.         }
  468.         return $this;
  469.     }
  470.     public function removeIncidentUpdate(IncidentUpdate $incidentUpdate): static
  471.     {
  472.         if ($this->incidentUpdates->removeElement($incidentUpdate)) {
  473.             // set the owning side to null (unless already changed)
  474.             if ($incidentUpdate->getCreatedBy() === $this) {
  475.                 $incidentUpdate->setCreatedBy(null);
  476.             }
  477.         }
  478.         return $this;
  479.     }
  480.     /**
  481.      * @return Collection<int, Service>
  482.      */
  483.     public function getServices(): Collection
  484.     {
  485.         return $this->services;
  486.     }
  487.     public function addService(Service $service): static
  488.     {
  489.         if (!$this->services->contains($service)) {
  490.             $this->services->add($service);
  491.             $service->setCreatedBy($this);
  492.         }
  493.         return $this;
  494.     }
  495.     public function removeService(Service $service): static
  496.     {
  497.         if ($this->services->removeElement($service)) {
  498.             // set the owning side to null (unless already changed)
  499.             if ($service->getCreatedBy() === $this) {
  500.                 $service->setCreatedBy(null);
  501.             }
  502.         }
  503.         return $this;
  504.     }
  505.     public function getAdress(): ?string
  506.     {
  507.         return $this->adress;
  508.     }
  509.     public function setAdress(?string $adress): static
  510.     {
  511.         $this->adress $adress;
  512.         return $this;
  513.     }
  514.     public function getCity(): ?string
  515.     {
  516.         return $this->city;
  517.     }
  518.     public function setCity(?string $city): static
  519.     {
  520.         $this->city $city;
  521.         return $this;
  522.     }
  523.     public function getProvince(): ?string
  524.     {
  525.         return $this->province;
  526.     }
  527.     public function setProvince(?string $province): static
  528.     {
  529.         $this->province $province;
  530.         return $this;
  531.     }
  532.     public function getCountry(): ?Country
  533.     {
  534.         return $this->country;
  535.     }
  536.     public function setCountry(?Country $country): static
  537.     {
  538.         $this->country $country;
  539.         return $this;
  540.     }
  541.     public function getLocataire(): ?Locataire
  542.     {
  543.         return $this->locataire;
  544.     }
  545.     public function setLocataire(?Locataire $locataire): static
  546.     {
  547.         $this->locataire $locataire;
  548.         return $this;
  549.     }
  550.     public function getMode(): ?string
  551.     {
  552.         return $this->mode;
  553.     }
  554.     public function setMode(?string $mode): static
  555.     {
  556.         $this->mode $mode;
  557.         return $this;
  558.     }
  559.     public function getLastAction(): ?\DateTimeInterface
  560.     {
  561.         return $this->lastAction;
  562.     }
  563.     public function setLastAction(?\DateTimeInterface $lastAction): static
  564.     {
  565.         $this->lastAction $lastAction;
  566.         return $this;
  567.     }
  568. }