src/Entity/User.php line 23
<?phpnamespace App\Entity;use App\Repository\UserRepository;use App\Traits\TimeStampTrait;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;use Symfony\Component\Security\Core\User\UserInterface;use Symfony\Component\Validator\Constraints as Assert;#[ORM\Table(name: 'User')]#[ORM\Entity(repositoryClass: UserRepository::class)]#[ORM\HasLifecycleCallbacks]#[UniqueEntity(fields: ['username'],message: 'Ce nom utilisateur est déjà pris.',)]class User implements UserInterface, PasswordAuthenticatedUserInterface{use TimeStampTrait;#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 180, unique: true)]private ?string $username = null;/*** @var string The hashed password*/#[ORM\Column]private ?string $password = null;#[ORM\ManyToOne(inversedBy: 'users')]private ?Role $role = null;#[ORM\Column(length: 50, nullable: true)]private ?string $name = null;#[ORM\Column(length: 50, nullable: true)]private ?string $lastname = null;#[ORM\Column(length: 100, nullable: true)]private ?string $code = null;#[ORM\Column(nullable: true)]private ?bool $status = null;#[ORM\Column(nullable: true)]private ?bool $reset = null;#[ORM\Column(length: 25, nullable: true)]private ?string $sexe = null;#[ORM\Column(length: 25, nullable: true)]private ?string $phone = null;#[ORM\Column(length: 150, nullable: true)]private ?string $picture = null;#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: Location::class)]private Collection $locations;#[ORM\ManyToOne(inversedBy: 'users')]private ?Entreprise $entreprise = null;#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'users')]private ?self $createdBy = null;#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: self::class)]private Collection $users;#[ORM\Column(nullable: true)]private ?bool $notif = null;/*** @Assert\NotBlank()* @Assert\Email()*/#[ORM\Column(length: 100, nullable: true)]private ?string $email = null;#[ORM\Column(length: 50, nullable: true)]private ?string $profil = null;#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: Country::class)]private Collection $countries;#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: Log::class)]private Collection $logs;#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: Template::class)]private Collection $templates;#[ORM\Column(nullable: true)]private ?int $level = null;#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: Incident::class)]private Collection $incidents;#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: IncidentUpdate::class)]private Collection $incidentUpdates;#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: Service::class)]private Collection $services;#[ORM\Column(length: 100, nullable: true)]private ?string $adress = null;#[ORM\Column(length: 50, nullable: true)]private ?string $city = null;#[ORM\Column(length: 50, nullable: true)]private ?string $province = null;#[ORM\ManyToOne(inversedBy: 'users')]private ?Country $country = null;#[ORM\ManyToMany(targetEntity: Announcement::class, mappedBy: 'user')]private Collection $announcements;#[ORM\Column(length: 25, nullable: true)]private ?string $mode = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $lastAction = null;#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: Reservation::class)]private Collection $reservations;#[ORM\OneToMany(mappedBy: 'user', targetEntity: UserEntreprise::class)]private Collection $userEntreprises;#[ORM\OneToMany(mappedBy: 'owner', targetEntity: Entreprise::class)]private Collection $entreprises;public function __construct(){$this->locations = new ArrayCollection();$this->users = new ArrayCollection();$this->countries = new ArrayCollection();$this->logs = new ArrayCollection();$this->templates = new ArrayCollection();$this->incidents = new ArrayCollection();$this->incidentUpdates = new ArrayCollection();$this->services = new ArrayCollection();$this->announcements = new ArrayCollection();$this->reservations = new ArrayCollection();$this->userEntreprises = new ArrayCollection();$this->entreprises = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getUsername(): ?string{return $this->username;}public function setUsername(string $username): self{$this->username = $username;return $this;}/*** A visual identifier that represents this user.** @see UserInterface*/public function getUserIdentifier(): string{return (string) $this->username;}/*** @see UserInterface*/public function getRoles(): array{$rs = [];$rs[] = 'ROLE_ADMIN';if ($this->role != null) {foreach ($this->role->getPrivilege() as $role){$rs[] = 'ROLE_'.$role->getlibelle();}}return $rs;}/*** @see PasswordAuthenticatedUserInterface*/public function getPassword(): string{return $this->password;}public function setPassword(string $password): self{$this->password = $password;return $this;}/*** @see UserInterface*/public function eraseCredentials(){// If you store any temporary, sensitive data on the user, clear it here// $this->plainPassword = null;}public function getRole(): ?Role{return $this->role;}public function setRole(?Role $role): self{$this->role = $role;return $this;}public function getName(): ?string{return $this->name;}public function setName(?string $name): self{$this->name = $name;return $this;}public function getLastname(): ?string{return $this->lastname;}public function setLastname(?string $lastname): self{$this->lastname = $lastname;return $this;}public function getCode(): ?string{return $this->code;}public function setCode(?string $code): self{$this->code = $code;return $this;}public function isStatus(): ?bool{return $this->status;}public function setStatus(?bool $status): self{$this->status = $status;return $this;}public function isReset(): ?bool{return $this->reset;}public function setReset(?bool $reset): self{$this->reset = $reset;return $this;}public function __toString(): string{return $this->name . ' ' . $this->lastname;}public function getSexe(): ?string{return $this->sexe;}public function setSexe(?string $sexe): static{$this->sexe = $sexe;return $this;}public function getPhone(): ?string{return $this->phone;}public function setPhone(?string $phone): static{$this->phone = $phone;return $this;}public function getPicture(): ?string{return $this->picture;}public function setPicture(?string $picture): static{$this->picture = $picture;return $this;}/*** @return Collection<int, Location>*/public function getLocations(): Collection{return $this->locations;}public function addLocation(Location $location): static{if (!$this->locations->contains($location)) {$this->locations->add($location);$location->setCreatedBy($this);}return $this;}public function removeLocation(Location $location): static{if ($this->locations->removeElement($location)) {// set the owning side to null (unless already changed)if ($location->getCreatedBy() === $this) {$location->setCreatedBy(null);}}return $this;}public function getEntreprise(): ?Entreprise{return $this->entreprise;}public function setEntreprise(?Entreprise $entreprise): static{$this->entreprise = $entreprise;return $this;}public function getCreatedBy(): ?self{return $this->createdBy;}public function setCreatedBy(?self $createdBy): static{$this->createdBy = $createdBy;return $this;}/*** @return Collection<int, self>*/public function getUsers(): Collection{return $this->users;}public function addUser(self $user): static{if (!$this->users->contains($user)) {$this->users->add($user);$user->setCreatedBy($this);}return $this;}public function removeUser(self $user): static{if ($this->users->removeElement($user)) {// set the owning side to null (unless already changed)if ($user->getCreatedBy() === $this) {$user->setCreatedBy(null);}}return $this;}public function isNotif(): ?bool{return $this->notif;}public function setNotif(?bool $notif): static{$this->notif = $notif;return $this;}public function getEmail(): ?string{return $this->email;}public function setEmail(?string $email): static{$this->email = $email;return $this;}public function getProfil(): ?string{return $this->profil;}public function setProfil(?string $profil): static{$this->profil = $profil;return $this;}/*** @return Collection<int, Country>*/public function getCountries(): Collection{return $this->countries;}public function addCountry(Country $country): static{if (!$this->countries->contains($country)) {$this->countries->add($country);$country->setCreatedBy($this);}return $this;}public function removeCountry(Country $country): static{if ($this->countries->removeElement($country)) {// set the owning side to null (unless already changed)if ($country->getCreatedBy() === $this) {$country->setCreatedBy(null);}}return $this;}/*** @return Collection<int, Log>*/public function getLogs(): Collection{return $this->logs;}public function addLog(Log $log): static{if (!$this->logs->contains($log)) {$this->logs->add($log);$log->setCreatedBy($this);}return $this;}public function removeLog(Log $log): static{if ($this->logs->removeElement($log)) {// set the owning side to null (unless already changed)if ($log->getCreatedBy() === $this) {$log->setCreatedBy(null);}}return $this;}/*** @return Collection<int, Template>*/public function getTemplates(): Collection{return $this->templates;}public function addTemplate(Template $template): static{if (!$this->templates->contains($template)) {$this->templates->add($template);$template->setCreatedBy($this);}return $this;}public function removeTemplate(Template $template): static{if ($this->templates->removeElement($template)) {// set the owning side to null (unless already changed)if ($template->getCreatedBy() === $this) {$template->setCreatedBy(null);}}return $this;}public function getLevel(): ?int{return $this->level;}public function setLevel(?int $level): static{$this->level = $level;return $this;}/*** @return Collection<int, Incident>*/public function getIncidents(): Collection{return $this->incidents;}public function addIncident(Incident $incident): static{if (!$this->incidents->contains($incident)) {$this->incidents->add($incident);$incident->setCreatedBy($this);}return $this;}public function removeIncident(Incident $incident): static{if ($this->incidents->removeElement($incident)) {// set the owning side to null (unless already changed)if ($incident->getCreatedBy() === $this) {$incident->setCreatedBy(null);}}return $this;}/*** @return Collection<int, IncidentUpdate>*/public function getIncidentUpdates(): Collection{return $this->incidentUpdates;}public function addIncidentUpdate(IncidentUpdate $incidentUpdate): static{if (!$this->incidentUpdates->contains($incidentUpdate)) {$this->incidentUpdates->add($incidentUpdate);$incidentUpdate->setCreatedBy($this);}return $this;}public function removeIncidentUpdate(IncidentUpdate $incidentUpdate): static{if ($this->incidentUpdates->removeElement($incidentUpdate)) {// set the owning side to null (unless already changed)if ($incidentUpdate->getCreatedBy() === $this) {$incidentUpdate->setCreatedBy(null);}}return $this;}/*** @return Collection<int, Service>*/public function getServices(): Collection{return $this->services;}public function addService(Service $service): static{if (!$this->services->contains($service)) {$this->services->add($service);$service->setCreatedBy($this);}return $this;}public function removeService(Service $service): static{if ($this->services->removeElement($service)) {// set the owning side to null (unless already changed)if ($service->getCreatedBy() === $this) {$service->setCreatedBy(null);}}return $this;}public function getAdress(): ?string{return $this->adress;}public function setAdress(?string $adress): static{$this->adress = $adress;return $this;}public function getCity(): ?string{return $this->city;}public function setCity(?string $city): static{$this->city = $city;return $this;}public function getProvince(): ?string{return $this->province;}public function setProvince(?string $province): static{$this->province = $province;return $this;}public function getCountry(): ?Country{return $this->country;}public function setCountry(?Country $country): static{$this->country = $country;return $this;}/*** @return Collection<int, Announcement>*/public function getAnnouncements(): Collection{return $this->announcements;}public function addAnnouncement(Announcement $announcement): static{if (!$this->announcements->contains($announcement)) {$this->announcements->add($announcement);$announcement->addUser($this);}return $this;}public function removeAnnouncement(Announcement $announcement): static{if ($this->announcements->removeElement($announcement)) {$announcement->removeUser($this);}return $this;}public function getMode(): ?string{return $this->mode;}public function setMode(?string $mode): static{$this->mode = $mode;return $this;}public function getLastAction(): ?\DateTimeInterface{return $this->lastAction;}public function setLastAction(?\DateTimeInterface $lastAction): static{$this->lastAction = $lastAction;return $this;}/*** @return Collection<int, Reservation>*/public function getReservations(): Collection{return $this->reservations;}public function addReservation(Reservation $reservation): static{if (!$this->reservations->contains($reservation)) {$this->reservations->add($reservation);$reservation->setCreatedBy($this);}return $this;}public function removeReservation(Reservation $reservation): static{if ($this->reservations->removeElement($reservation)) {// set the owning side to null (unless already changed)if ($reservation->getCreatedBy() === $this) {$reservation->setCreatedBy(null);}}return $this;}/*** @return Collection<int, UserEntreprise>*/public function getUserEntreprises(): Collection{return $this->userEntreprises;}public function addUserEntreprise(UserEntreprise $userEntreprise): static{if (!$this->userEntreprises->contains($userEntreprise)) {$this->userEntreprises->add($userEntreprise);$userEntreprise->setUser($this);}return $this;}public function removeUserEntreprise(UserEntreprise $userEntreprise): static{if ($this->userEntreprises->removeElement($userEntreprise)) {// set the owning side to null (unless already changed)if ($userEntreprise->getUser() === $this) {$userEntreprise->setUser(null);}}return $this;}/*** @return Collection<int, Entreprise>*/public function getEntreprises(): Collection{return $this->entreprises;}public function addEntreprise(Entreprise $entreprise): static{if (!$this->entreprises->contains($entreprise)) {$this->entreprises->add($entreprise);$entreprise->setOwner($this);}return $this;}public function removeEntreprise(Entreprise $entreprise): static{if ($this->entreprises->removeElement($entreprise)) {// set the owning side to null (unless already changed)if ($entreprise->getOwner() === $this) {$entreprise->setOwner(null);}}return $this;}}